From 925fbab86db420d710301231b5ee28709c3d7b1a Mon Sep 17 00:00:00 2001 From: paisley <8197966+su8su@users.noreply.github.com> Date: Mon, 16 Mar 2026 19:51:19 +0800 Subject: [PATCH] fix clawx win uninstall (#533) --- scripts/installer.nsh | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/scripts/installer.nsh b/scripts/installer.nsh index c8c0f2309..789191363 100644 --- a/scripts/installer.nsh +++ b/scripts/installer.nsh @@ -115,11 +115,66 @@ /SD IDNO IDYES _cu_removeData IDNO _cu_skipRemove _cu_removeData: + ; Kill any lingering ClawX processes to release file locks on electron-store + ; JSON files (settings.json, clawx-providers.json, window-state.json, etc.) + ${nsProcess::FindProcess} "${APP_EXECUTABLE_FILENAME}" $R0 + ${if} $R0 == 0 + ${nsProcess::KillProcess} "${APP_EXECUTABLE_FILENAME}" $R0 + ${endIf} + ${nsProcess::Unload} + + ; Wait for processes to fully exit and release file handles + Sleep 2000 + ; --- Always remove current user's data first --- RMDir /r "$PROFILE\.openclaw" RMDir /r "$LOCALAPPDATA\clawx" RMDir /r "$APPDATA\clawx" + ; --- Retry: if directories still exist (locked files), wait and try again --- + ; Check .openclaw + IfFileExists "$PROFILE\.openclaw\*.*" 0 _cu_openclawDone + Sleep 3000 + RMDir /r "$PROFILE\.openclaw" + IfFileExists "$PROFILE\.openclaw\*.*" 0 _cu_openclawDone + nsExec::ExecToStack 'cmd.exe /c rd /s /q "$PROFILE\.openclaw"' + Pop $0 + Pop $1 + _cu_openclawDone: + + ; Check AppData\Local\clawx + IfFileExists "$LOCALAPPDATA\clawx\*.*" 0 _cu_localDone + Sleep 3000 + RMDir /r "$LOCALAPPDATA\clawx" + IfFileExists "$LOCALAPPDATA\clawx\*.*" 0 _cu_localDone + nsExec::ExecToStack 'cmd.exe /c rd /s /q "$LOCALAPPDATA\clawx"' + Pop $0 + Pop $1 + _cu_localDone: + + ; Check AppData\Roaming\clawx + IfFileExists "$APPDATA\clawx\*.*" 0 _cu_roamingDone + Sleep 3000 + RMDir /r "$APPDATA\clawx" + IfFileExists "$APPDATA\clawx\*.*" 0 _cu_roamingDone + nsExec::ExecToStack 'cmd.exe /c rd /s /q "$APPDATA\clawx"' + Pop $0 + Pop $1 + _cu_roamingDone: + + ; --- Final check: warn user if any directories could not be removed --- + StrCpy $R3 "" + IfFileExists "$PROFILE\.openclaw\*.*" 0 +2 + StrCpy $R3 "$R3$\r$\n • $PROFILE\.openclaw" + IfFileExists "$LOCALAPPDATA\clawx\*.*" 0 +2 + StrCpy $R3 "$R3$\r$\n • $LOCALAPPDATA\clawx" + IfFileExists "$APPDATA\clawx\*.*" 0 +2 + StrCpy $R3 "$R3$\r$\n • $APPDATA\clawx" + StrCmp $R3 "" _cu_cleanupOk + MessageBox MB_OK|MB_ICONEXCLAMATION \ + "Some data directories could not be removed (files may be in use):$\r$\n$R3$\r$\n$\r$\nPlease delete them manually after restarting your computer." + _cu_cleanupOk: + ; --- For per-machine (all users) installs, enumerate all user profiles --- StrCpy $R0 0