From e41b3bb833f687d483e3ee95f6895d27b0706c56 Mon Sep 17 00:00:00 2001 From: isaak654 Date: Sun, 17 Nov 2024 18:08:40 +0100 Subject: [PATCH] Update Sandboxie-Plus.iss --- Installer/Sandboxie-Plus.iss | 123 ++++------------------------------- 1 file changed, 11 insertions(+), 112 deletions(-) diff --git a/Installer/Sandboxie-Plus.iss b/Installer/Sandboxie-Plus.iss index 72d3bb60..b6a06da7 100644 --- a/Installer/Sandboxie-Plus.iss +++ b/Installer/Sandboxie-Plus.iss @@ -139,6 +139,17 @@ Filename: "{app}\Start.exe"; Parameters: "open_agent:sandman.exe"; Description: Type: dirifempty; Name: "{app}" Type: files; Name: "{localappdata}\{#MyAppName}\addons.json" Type: dirifempty; Name: "{localappdata}\{#MyAppName}" +Type: files; Name: "{localappdata}\Temp\qtsingleapp-sandma-*" +Type: dirifempty; Name: "{localappdata}\Temp\sandboxie-updater" +Type: files; Name: "{win}\Prefetch\KMDUTIL.EXE-*.pf" +Type: files; Name: "{win}\Prefetch\SANDBOXIE-PLUS*.pf" +Type: files; Name: "{win}\Prefetch\SANDBOXIEDCOMLAUNCH.EXE-*.pf" +Type: files; Name: "{win}\Prefetch\SANDBOXIERPCSS.EXE-*.pf" +Type: files; Name: "{win}\Prefetch\SANDMAN.EXE-*.pf" +Type: files; Name: "{win}\Prefetch\SBIECTRL.EXE-*.pf" +Type: files; Name: "{win}\Prefetch\SBIESVC.EXE-*.pf" +Type: files; Name: "{win}\Prefetch\START.EXE-*.pf" +Type: files; Name: "{win}\Prefetch\UPDUTIL.EXE-*.pf" [Messages] @@ -644,115 +655,6 @@ begin end; end; -function IsAdmin: Boolean; -begin - Result := True; -end; - -procedure DeleteSandboxiePlusLeftovers; -var - RegKeys: array[0..2] of string; - I, J: Integer; - RegValueName: string; - FilePatterns: array[0..9] of string; - DirPattern: string; -begin - // Define registry keys to clean up. - RegKeys[0] := 'Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache'; - RegKeys[1] := 'Software\Microsoft\Windows\CurrentVersion\UFH\SHC'; - RegKeys[2] := 'Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store'; - - // Iterate over the registry paths. - for I := 0 to High(RegKeys) do - begin - // Check if the registry key exists. - if RegKeyExists(HKEY_CURRENT_USER, RegKeys[I]) then - begin - // Try to delete values that may contain "Sandboxie-Plus". - J := 0; - while True do - begin - // Attempt to get a value name at index J - // Note: RegEnumValue doesn't exist in Inno Setup, so we manually try to access values. - // You may want to manually add known value names or add a pattern match. - - // Attempt to get the value data for the current index (J) under the key. - if RegQueryStringValue(HKEY_CURRENT_USER, RegKeys[I], 'ValueName' + IntToStr(J), RegValueName) then - begin - // If the value contains "Sandboxie-Plus", delete it. - if Pos('Sandboxie-Plus', RegValueName) > 0 then - begin - if RegDeleteValue(HKEY_CURRENT_USER, RegKeys[I], 'ValueName' + IntToStr(J)) then - Log('Deleted registry value: ValueName' + IntToStr(J) + ' under ' + RegKeys[I]) - else - Log('Failed to delete registry value: ValueName' + IntToStr(J) + ' under ' + RegKeys[I]); - end; - end - else - begin - // If no value is found at this index, break out of the loop. - Break; - end; - Inc(J); // Increment to check the next value - end; - end - else - begin - Log('Registry key does not exist: ' + RegKeys[I]); - end; - end; - - // Attempt to delete Prefetch files only if the installer is running with admin privileges. - if IsAdmin then - begin - // Define file patterns to clean up. - FilePatterns[0] := '{win}\Prefetch\KMDUTIL.EXE-*.pf'; - FilePatterns[1] := '{win}\Prefetch\SANDBOXIE-PLUS-*.pf'; - FilePatterns[2] := '{win}\Prefetch\SANDBOXIEDCOMLAUNCH.EXE-*.pf'; - FilePatterns[3] := '{win}\Prefetch\SANDBOXIERPCSS.EXE-*.pf'; - FilePatterns[4] := '{win}\Prefetch\SANDMAN.EXE-*.pf'; - FilePatterns[5] := '{win}\Prefetch\SBIECTRL.EXE-*.pf'; - FilePatterns[6] := '{win}\Prefetch\SBIESVC.EXE-*.pf'; - FilePatterns[7] := '{win}\Prefetch\START.EXE-*.pf'; - FilePatterns[8] := '{win}\Prefetch\UPDUTIL.EXE-*.pf'; - FilePatterns[9] := '{localappdata}\Temp\qtsingleapp-sandma-*'; - - // Attempt to delete files matching the patterns above (if admin rights are available). - for I := 0 to High(FilePatterns) do - begin - if FileExists(ExpandConstant(FilePatterns[I])) then - begin - if DeleteFile(ExpandConstant(FilePatterns[I])) then - begin - // Log successful deletion of the file. - Log('Deleted file: ' + ExpandConstant(FilePatterns[I])); - end - else - begin - // Log that the file could not be deleted due to permission issues. - Log('Failed to delete (permission denied): ' + ExpandConstant(FilePatterns[I])); - end; - end; - end; - end - else - begin - // Log that Prefetch file deletion was skipped due to lack of admin privileges. - Log('Skipped Prefetch file deletion due to lack of admin privileges.'); - end; - - // Define the single directory to clean up. - DirPattern := '{localappdata}\Temp\sandboxie-updater'; - - // Delete the directory if it exists. - if DirExists(ExpandConstant(DirPattern)) then - begin - if DelTree(ExpandConstant(DirPattern), True, True, True) then - Log('Deleted directory: ' + ExpandConstant(DirPattern)) - else - Log('Failed to delete directory: ' + ExpandConstant(DirPattern)); - end; -end; ////////////////////////////////////////////////////// // Uninstallation Events @@ -785,7 +687,4 @@ begin // Remove shell integration. ShellUninstall(); - // Call the cleanup procedure. - DeleteSandboxiePlusLeftovers; - end;