[client] Close the UI before InstallValidate in the MSI

The WiX CloseApplication action runs deferred, right before InstallFiles.
By then InstallValidate has already asked Restart Manager about the files
in use. When msiexec runs as LocalSystem (third-party deployment tools,
scheduled tasks) and netbird-ui.exe runs in the interactive user's
session, Restart Manager reports a session mismatch, so the installer
schedules the UI binary for replacement on the next reboot and returns
3010. Killing the UI afterwards is too late, the file stays on the old
version until a real reboot happens.

Replace the CloseApplication with an immediate WixQuietExec custom action
running taskkill /F /IM netbird-ui.exe, scheduled before InstallValidate.
The file is no longer held open when the in-use check runs, InstallFiles
overwrites it directly and no reboot is scheduled. Return is ignored
because taskkill exits non-zero when no UI is running. The action also
runs on uninstall so removal does not require a reboot either.
This commit is contained in:
Zoltán Papp
2026-09-02 10:54:16 +02:00
parent 2f55965031
commit 67834d1b92
+4 -1
View File
@@ -74,7 +74,9 @@
</ComponentGroup>
<util:CloseApplication Id="CloseNetBird" CloseMessage="no" Target="netbird.exe" RebootPrompt="no" />
<util:CloseApplication Id="CloseNetBirdUI" CloseMessage="no" Target="netbird-ui.exe" RebootPrompt="no" TerminateProcess="0" />
<SetProperty Id="WixQuietExecCmdLine" Value="&quot;[System64Folder]taskkill.exe&quot; /F /IM netbird-ui.exe" Before="KillNetBirdUI" Sequence="execute" />
<CustomAction Id="KillNetBirdUI" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec" Execute="immediate" Return="ignore" />
<!-- WebView2 evergreen runtime detection.
Probe both the per-machine and per-user EdgeUpdate keys; if either
@@ -104,6 +106,7 @@
Return="check" />
<InstallExecuteSequence>
<Custom Action="KillNetBirdUI" Before="InstallValidate" />
<Custom Action="InstallWebView2" Before="InstallFinalize"
Condition="NOT WEBVIEW2_VERSION_HKLM AND NOT WEBVIEW2_VERSION_HKCU AND NOT REMOVE" />
</InstallExecuteSequence>