Var TexrraCleanupDistro Var TexrraCleanupDistroArg Var TexrraCleanupPath Var TexrraCleanupWsl Var TexrraCleanupMode Var TexrraCleanupStatus ; Match the desktop launcher's Windows argument quoting. Some WSL builds ; treat unnecessary quotes around a distribution name as part of its name. !macro TexrraValidateDistro StrCpy $2 0 StrCpy $TexrraCleanupDistroArg $TexrraCleanupDistro ${Do} StrCpy $1 $TexrraCleanupDistro 1 $2 ${IfThen} $1 == "" ${|} ${ExitDo} ${|} ${If} $1 == "$\"" ${OrIf} $1 == "\" ${OrIf} $1 == "$\r" ${OrIf} $1 == "$\n" Goto texrra_cleanup_unavailable ${EndIf} ${If} $1 == " " ${OrIf} $1 == "$\t" StrCpy $TexrraCleanupDistroArg '$\"$TexrraCleanupDistro$\"' ${EndIf} IntOp $2 $2 + 1 ${Loop} !macroend !macro TexrraRunWslCleanup action options ${If} $TexrraCleanupDistro == "" nsExec::Exec ${options} '"$TexrraCleanupWsl" --cd "$PLUGINSDIR" --exec python3 -B ./uninstall-projects.py ${action}' ${Else} nsExec::Exec ${options} '"$TexrraCleanupWsl" --distribution $TexrraCleanupDistroArg --cd "$PLUGINSDIR" --exec python3 -B ./uninstall-projects.py ${action}' ${EndIf} Pop $TexrraCleanupStatus !macroend !macro TexrraReadCleanupFile name output ClearErrors FileOpen $0 "$PLUGINSDIR\${name}" r IfErrors texrra_cleanup_unavailable FileReadUTF16LE $0 ${output} FileClose $0 ${IfThen} ${output} == "" ${|} Goto texrra_cleanup_unavailable ${|} !macroend !macro NSIS_HOOK_PREUNINSTALL ; Updates, automated uninstalls and elevated accounts always preserve projects. ${If} ${Silent} ${OrIf} $PassiveMode = 1 ${OrIf} $UpdateMode = 1 ${OrIf} $DeleteAppDataCheckboxState <> 1 Goto texrra_cleanup_done ${EndIf} ReadRegStr $0 HKCU "${MANUPRODUCTKEY}" "" ${IfThen} $0 != $INSTDIR ${|} Goto texrra_cleanup_done ${|} System::Call 'shell32::IsUserAnAdmin() i .r0' ${IfThen} $0 != 0 ${|} Goto texrra_cleanup_done ${|} ${If} ${FileExists} "$INSTDIR\backend\bin\native_editor.exe" ${AndIfNot} ${FileExists} "$INSTDIR\backend\wsl-launch.py" ReadEnvStr $0 "LOCALAPPDATA" ${IfThen} $0 != $LOCALAPPDATA ${|} Goto texrra_cleanup_unavailable ${|} StrCpy $TexrraCleanupMode "native" ${ElseIf} ${FileExists} "$INSTDIR\backend\wsl-launch.py" ${AndIfNot} ${FileExists} "$INSTDIR\backend\bin\native_editor.exe" StrCpy $TexrraCleanupMode "wsl" ${Else} Goto texrra_cleanup_done ${EndIf} !insertmacro CheckIfAppIsRunning "$INSTDIR\${MAINBINARYNAME}.exe" "${PRODUCTNAME}" InitPluginsDir DetailPrint "Checking the Texrra project location..." ${If} $TexrraCleanupMode == "native" nsExec::Exec /TIMEOUT=20000 '"$INSTDIR\${MAINBINARYNAME}.exe" --uninstall-projects inspect "$PLUGINSDIR"' Pop $TexrraCleanupStatus ${Else} StrCpy $TexrraCleanupWsl "$WINDIR\Sysnative\wsl.exe" ${IfNot} ${FileExists} "$TexrraCleanupWsl" StrCpy $TexrraCleanupWsl "$SYSDIR\wsl.exe" ${IfNot} ${FileExists} "$TexrraCleanupWsl" Goto texrra_cleanup_unavailable ${EndIf} ${EndIf} ReadEnvStr $TexrraCleanupDistro "TEXRRA_WSL_DISTRO" !insertmacro TexrraValidateDistro Push $OUTDIR SetOutPath "$PLUGINSDIR" File /oname=uninstall-projects.py "${TAURIDIR}/uninstall-projects.py" Pop $0 SetOutPath $0 !insertmacro TexrraRunWslCleanup "inspect" "/TIMEOUT=20000" ${EndIf} ${IfThen} $TexrraCleanupStatus == 2 ${|} Goto texrra_cleanup_done ${|} ${IfThen} $TexrraCleanupStatus != 0 ${|} Goto texrra_cleanup_unavailable ${|} !insertmacro TexrraReadCleanupFile "projects-path.txt" "$TexrraCleanupPath" ${If} $TexrraCleanupMode == "wsl" !insertmacro TexrraReadCleanupFile "projects-distro.txt" "$TexrraCleanupDistro" !insertmacro TexrraValidateDistro MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_DEFBUTTON2 \ "Permanently delete all Texrra project files in this folder?$\r$\n$\r$\nWSL distribution: $TexrraCleanupDistro$\r$\n$TexrraCleanupPath" \ IDYES texrra_cleanup_delete ${Else} MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_DEFBUTTON2 \ "Permanently delete all Texrra project files in this folder?$\r$\n$\r$\n$TexrraCleanupPath" \ IDYES texrra_cleanup_delete ${EndIf} Goto texrra_cleanup_done texrra_cleanup_delete: !insertmacro CheckIfAppIsRunning "$INSTDIR\${MAINBINARYNAME}.exe" "${PRODUCTNAME}" DetailPrint "Deleting projects in $TexrraCleanupPath..." ${If} $TexrraCleanupMode == "native" nsExec::Exec '"$INSTDIR\${MAINBINARYNAME}.exe" --uninstall-projects delete "$PLUGINSDIR"' Pop $TexrraCleanupStatus ${Else} !insertmacro TexrraRunWslCleanup "delete" "" ${EndIf} ${If} $TexrraCleanupStatus != 0 MessageBox MB_OK|MB_ICONEXCLAMATION "Texrra could not finish deleting all files in:$\r$\n$TexrraCleanupPath" ${EndIf} Goto texrra_cleanup_done texrra_cleanup_unavailable: MessageBox MB_OK|MB_ICONEXCLAMATION "Texrra could not safely open the project folder. Project files will be kept." texrra_cleanup_done: !macroend