aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--installer/customactions.c26
-rw-r--r--installer/wireguard.wxs16
2 files changed, 34 insertions, 8 deletions
diff --git a/installer/customactions.c b/installer/customactions.c
index 72ee0ae3..b7aee8c1 100644
--- a/installer/customactions.c
+++ b/installer/customactions.c
@@ -82,6 +82,32 @@ static void log_errorf(MSIHANDLE installer, enum log_level level, DWORD error_co
LocalFree(system_message);
}
+__declspec(dllexport) UINT __stdcall LaunchApplicationAndAbort(MSIHANDLE installer)
+{
+ UINT ret = ERROR_INSTALL_FAILURE;
+ TCHAR path[MAX_PATH];
+ DWORD path_len = _countof(path);
+ PROCESS_INFORMATION pi;
+ STARTUPINFO si = { .cb = sizeof(STARTUPINFO) };
+
+ ret = MsiGetProperty(installer, TEXT("WireGuardFolder"), path, &path_len);
+ if (ret != ERROR_SUCCESS) {
+ log_errorf(installer, LOG_LEVEL_WARN, ret, TEXT("MsiGetProperty(\"WireGuardFolder\") failed"));
+ goto out;
+ }
+ if (!path[0] || !PathAppend(path, TEXT("wireguard.exe")))
+ goto out;
+ log_messagef(installer, LOG_LEVEL_INFO, TEXT("Launching %1"), path);
+ if (!CreateProcess(path, TEXT("wireguard"), NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
+ log_errorf(installer, LOG_LEVEL_WARN, GetLastError(), TEXT("Failed to create \"%1\" process"), path);
+ goto out;
+ }
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+out:
+ return ERROR_INSTALL_USEREXIT;
+}
+
static UINT insert_service_control(MSIHANDLE installer, MSIHANDLE view, const TCHAR *service_name, bool start)
{
static unsigned int index = 0;
diff --git a/installer/wireguard.wxs b/installer/wireguard.wxs
index 71445560..2757c882 100644
--- a/installer/wireguard.wxs
+++ b/installer/wireguard.wxs
@@ -108,6 +108,14 @@
</InstallExecuteSequence>
<!--
+ Launch wireguard.exe on product reconfiguration (starting same MSI again)
+ -->
+ <CustomAction Id="LaunchApplicationAndAbort" BinaryKey="customactions.dll" DllEntry="LaunchApplicationAndAbort" />
+ <InstallExecuteSequence>
+ <Custom Action="LaunchApplicationAndAbort" After="CostFinalize">ProductState=5 AND NOT REMOVE AND NOT DO_NOT_LAUNCH</Custom>
+ </InstallExecuteSequence>
+
+ <!--
Evaluate WireGuard services and populate ServiceControl table
-->
<CustomAction Id="EvaluateWireGuardServices" BinaryKey="customactions.dll" DllEntry="EvaluateWireGuardServices" />
@@ -154,13 +162,5 @@
<InstallExecuteSequence>
<Custom Action="LaunchApplication" Before="InstallFinalize">(&amp;WireGuardFeature = 3) AND NOT DO_NOT_LAUNCH</Custom>
</InstallExecuteSequence>
-
- <!--
- Launch wireguard.exe on product reconfiguration (starting same MSI again)
- -->
- <CustomAction Id="LaunchApplicationAsOrdinaryUser" HideTarget="yes" FileKey="wireguard.exe" ExeCommand="" Return="asyncNoWait" />
- <InstallExecuteSequence>
- <Custom Action="LaunchApplicationAsOrdinaryUser" After="InstallFinalize">(&amp;WireGuardFeature = -1) AND (!WireGuardFeature = 3) AND NOT DO_NOT_LAUNCH</Custom>
- </InstallExecuteSequence>
</Product>
</Wix>