From 332b62bbe0b67adea9c8b99daaaaaea3159dc1f3 Mon Sep 17 00:00:00 2001 From: 7418 <7418@openclaw.ai> Date: Fri, 13 Feb 2026 17:56:40 +0800 Subject: [PATCH] fix: prevent uninstall from deleting user files and fix Windows process cleanup Two fixes for critical Windows issues (#81): 1. NSIS installer: disable allowToChangeInstallationDirectory to prevent users from installing into shared directories where uninstall would delete all their files. Also set deleteAppDataOnUninstall: false to preserve user data. 2. Windows process cleanup: killServer() used SIGTERM which Windows doesn't support, leaving zombie processes that block updates. Now uses taskkill /T /F to kill the entire process tree on Windows, ensuring no residual processes remain after app exit. Co-Authored-By: Claude Opus 4.6 --- electron-builder.yml | 3 ++- electron/main.ts | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/electron-builder.yml b/electron-builder.yml index 7377a15..9b8c54a 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -54,9 +54,10 @@ win: nsis: oneClick: false perMachine: false - allowToChangeInstallationDirectory: true + allowToChangeInstallationDirectory: false createDesktopShortcut: true createStartMenuShortcut: true + deleteAppDataOnUninstall: false linux: icon: build/icon.png category: Development diff --git a/electron/main.ts b/electron/main.ts index 4936757..9122169 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -55,9 +55,15 @@ function killServer(): Promise { const pid = serverProcess.pid; const timeout = setTimeout(() => { - // Force kill via Node's process.kill with SIGKILL + // Force kill — on Windows use taskkill to kill the entire process tree if (pid) { - try { process.kill(pid, 'SIGKILL'); } catch { /* already dead */ } + try { + if (process.platform === 'win32') { + spawn('taskkill', ['/T', '/F', '/PID', String(pid)], { stdio: 'ignore' }); + } else { + process.kill(pid, 'SIGKILL'); + } + } catch { /* already dead */ } } serverProcess = null; resolve(); @@ -69,8 +75,12 @@ function killServer(): Promise { resolve(); }); - // UtilityProcess.kill() sends SIGTERM - serverProcess.kill(); + // On Windows, SIGTERM is not supported — use taskkill to kill the tree + if (process.platform === 'win32' && pid) { + spawn('taskkill', ['/T', '/F', '/PID', String(pid)], { stdio: 'ignore' }); + } else { + serverProcess.kill(); + } }); }