aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2023-01-20 10:02:27 +0100
committerSimon Rozman <simon@rozman.si>2023-01-23 14:22:34 +0100
commitdcc0eb72a04ba2c0c83d29bd621a7f66acce0a23 (patch)
tree505e17d8e6e6d52461105b538d8e4d64b8d8d0f2
parentembeddable-dll-service: build: .gitignore outputs (diff)
downloadwireguard-windows-master.tar.xz
wireguard-windows-master.zip
fetcher: add /noprompt switchHEADmaster
Deploying WireGuard MSI using Microsoft Endpoint Manager (aka MS Intune) falls short with poor Microsoft Endpoint Manager support: no ARM64 support, requires multiple per-architecture deployments... Fetcher proves super-useful for automating WireGuard install. It contains platform selection logic, MSI download, integrity check... However, automated installation is an unattended process and the wireguard-installer.exe must not block the process for any user prompts. Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r--installer/fetcher/fetcher.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/installer/fetcher/fetcher.c b/installer/fetcher/fetcher.c
index b3fbc994..5c688997 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 @@ out:
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",