Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(windows): stop bundled sidecars before NSIS updates (#3650)

Ansh Groverb66e8b461b9e
diff --git a/apps/screenpipe-app-tauri/src-tauri/windows/hooks.nsh b/apps/screenpipe-app-tauri/src-tauri/windows/hooks.nsh
index f7b3550fd..4e8bf618e 100644
--- a/apps/screenpipe-app-tauri/src-tauri/windows/hooks.nsh
+++ b/apps/screenpipe-app-tauri/src-tauri/windows/hooks.nsh
@@ -1,8 +1,12 @@
!macro NSIS_HOOK_PREINSTALL
- ; Kill screenpipe processes before installation
- nsExec::ExecToLog 'taskkill /F /IM screenpipe.exe'
- nsExec::ExecToLog 'taskkill /F /IM screenpipe-app.exe'
- ; Wait a moment for processes to fully terminate and release file handles
+ ; Kill screenpipe processes before installation.
+ nsExec::ExecToLog 'taskkill /F /T /IM screenpipe.exe'
+ nsExec::ExecToLog 'taskkill /F /T /IM screenpipe-app.exe'
+ ; Stop any remaining process running from this install directory, including
+ ; the bundled Bun sidecar. Use CIM ExecutablePath instead of Get-Process.Path:
+ ; reading process module paths can throw "Access to the path is denied".
+ nsExec::ExecToLog 'powershell -NoProfile -ExecutionPolicy Bypass -Command "$$root = [System.IO.Path]::GetFullPath(''$INSTDIR'').TrimEnd(''\'') + ''\''; Get-CimInstance Win32_Process | Where-Object { $$_.ExecutablePath -and $$_.ExecutablePath.StartsWith($$root, [System.StringComparison]::OrdinalIgnoreCase) } | ForEach-Object { $$pidToStop = $$_.ProcessId; Stop-Process -Id $$pidToStop -Force -ErrorAction SilentlyContinue; Wait-Process -Id $$pidToStop -Timeout 5 -ErrorAction SilentlyContinue }"'
+ ; Wait a moment for processes to fully terminate and release file handles.
Sleep 1000
!macroend