diff --git a/installer/fetcher/fetcher.c b/installer/fetcher/fetcher.c index b3fbc9949..5c6889979 100644 --- a/installer/fetcher/fetcher.c +++ b/installer/fetcher/fetcher.c @@ -23,7 +23,7 @@ #include "constants.h" static char msi_filename[MAX_PATH]; -static volatile bool msi_filename_is_set; +static volatile bool msi_filename_is_set, prompts = true; static volatile size_t g_current, g_total; static HWND progress; static HANDLE filehandle = INVALID_HANDLE_VALUE; @@ -208,7 +208,7 @@ static DWORD __stdcall download_thread(void *param) if (security_attributes.lpSecurityDescriptor) LocalFree(security_attributes.lpSecurityDescriptor); - if (ret) { + if (ret && prompts) { ShowWindow(progress, SW_SHOWDEFAULT); if (MessageBoxA(progress, "Something went wrong when downloading the WireGuard installer. Would you like to open your web browser to the MSI download page?", "Download Error", MB_YESNO | MB_ICONWARNING) == IDYES) ShellExecuteA(progress, NULL, "https://" server msi_path, NULL, NULL, SW_SHOWNORMAL); @@ -285,6 +285,20 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar return DefSubclassProc(hWnd, uMsg, wParam, lParam); } +static void parse_command_line(void) +{ + LPWSTR *argv; + int argc; + argv = CommandLineToArgvW(GetCommandLineW(), &argc); + if (!argv) + return; + for (int i = 1; i < argc; ++i) { + if (wcsicmp(argv[i], L"/noprompt") == 0) + prompts = false; + } + LocalFree(argv); +} + int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow) { MSG msg; @@ -297,6 +311,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, if (!SetDllDirectoryA("") || !SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32)) return 1; + parse_command_line(); + InitCommonControlsEx(&(INITCOMMONCONTROLSEX){ .dwSize = sizeof(INITCOMMONCONTROLSEX), .dwICC = ICC_PROGRESS_CLASS }); progress = CreateWindowExA(0, PROGRESS_CLASS, "WireGuard Installer",