mirror of
https://github.com/fosrl/olm.git
synced 2025-12-05 19:17:35 -06:00
152 lines
5.5 KiB
Plaintext
152 lines
5.5 KiB
Plaintext
; Script generated by the Inno Setup Script Wizard.
|
|
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
|
|
|
#define MyAppName "olm"
|
|
#define MyAppVersion "1.0.0"
|
|
#define MyAppPublisher "Fossorial Inc."
|
|
#define MyAppURL "https://pangolin.net"
|
|
#define MyAppExeName "olm.exe"
|
|
|
|
[Setup]
|
|
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
|
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
|
AppId={{44A24E4C-B616-476F-ADE7-8D56B930959E}
|
|
AppName={#MyAppName}
|
|
AppVersion={#MyAppVersion}
|
|
;AppVerName={#MyAppName} {#MyAppVersion}
|
|
AppPublisher={#MyAppPublisher}
|
|
AppPublisherURL={#MyAppURL}
|
|
AppSupportURL={#MyAppURL}
|
|
AppUpdatesURL={#MyAppURL}
|
|
DefaultDirName={autopf}\{#MyAppName}
|
|
UninstallDisplayIcon={app}\{#MyAppExeName}
|
|
; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run
|
|
; on anything but x64 and Windows 11 on Arm.
|
|
ArchitecturesAllowed=x64compatible
|
|
; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the
|
|
; install be done in "64-bit mode" on x64 or Windows 11 on Arm,
|
|
; meaning it should use the native 64-bit Program Files directory and
|
|
; the 64-bit view of the registry.
|
|
ArchitecturesInstallIn64BitMode=x64compatible
|
|
DefaultGroupName={#MyAppName}
|
|
DisableProgramGroupPage=yes
|
|
; Uncomment the following line to run in non administrative install mode (install for current user only).
|
|
;PrivilegesRequired=lowest
|
|
OutputBaseFilename=mysetup
|
|
SolidCompression=yes
|
|
WizardStyle=modern
|
|
; Add this to ensure PATH changes are applied and the system is prompted for a restart if needed
|
|
RestartIfNeededByRun=no
|
|
ChangesEnvironment=true
|
|
|
|
[Languages]
|
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
|
|
|
[Files]
|
|
; The 'DestName' flag ensures that 'olm_windows_amd64.exe' is installed as 'olm.exe'
|
|
Source: "C:\Users\Administrator\Downloads\olm_windows_amd64.exe"; DestDir: "{app}"; DestName: "{#MyAppExeName}"; Flags: ignoreversion
|
|
Source: "C:\Users\Administrator\Downloads\wintun.dll"; DestDir: "{app}"; Flags: ignoreversion
|
|
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
|
|
|
[Icons]
|
|
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
|
|
|
[Registry]
|
|
; Add the application's installation directory to the system PATH environment variable.
|
|
; HKLM (HKEY_LOCAL_MACHINE) is used for system-wide changes.
|
|
; The 'Path' variable is located under 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'.
|
|
; ValueType: expandsz allows for environment variables (like %ProgramFiles%) in the path.
|
|
; ValueData: "{olddata};{app}" appends the current application directory to the existing PATH.
|
|
; Note: Removal during uninstallation is handled by CurUninstallStepChanged procedure in [Code] section.
|
|
; Check: NeedsAddPath ensures this is applied only if the path is not already present.
|
|
[Registry]
|
|
; Add the application's installation directory to the system PATH.
|
|
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
|
|
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; \
|
|
Check: NeedsAddPath(ExpandConstant('{app}'))
|
|
|
|
[Code]
|
|
function NeedsAddPath(Path: string): boolean;
|
|
var
|
|
OrigPath: string;
|
|
begin
|
|
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
|
|
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
|
|
'Path', OrigPath)
|
|
then begin
|
|
// Path variable doesn't exist at all, so we definitely need to add it.
|
|
Result := True;
|
|
exit;
|
|
end;
|
|
|
|
// Perform a case-insensitive check to see if the path is already present.
|
|
// We add semicolons to prevent partial matches (e.g., matching C:\App in C:\App2).
|
|
if Pos(';' + UpperCase(Path) + ';', ';' + UpperCase(OrigPath) + ';') > 0 then
|
|
Result := False
|
|
else
|
|
Result := True;
|
|
end;
|
|
|
|
procedure RemovePathEntry(PathToRemove: string);
|
|
var
|
|
OrigPath: string;
|
|
NewPath: string;
|
|
PathList: TStringList;
|
|
I: Integer;
|
|
begin
|
|
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
|
|
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
|
|
'Path', OrigPath)
|
|
then begin
|
|
// Path variable doesn't exist, nothing to remove
|
|
exit;
|
|
end;
|
|
|
|
// Create a string list to parse the PATH entries
|
|
PathList := TStringList.Create;
|
|
try
|
|
// Split the PATH by semicolons
|
|
PathList.Delimiter := ';';
|
|
PathList.StrictDelimiter := True;
|
|
PathList.DelimitedText := OrigPath;
|
|
|
|
// Find and remove the matching entry (case-insensitive)
|
|
for I := PathList.Count - 1 downto 0 do
|
|
begin
|
|
if CompareText(Trim(PathList[I]), Trim(PathToRemove)) = 0 then
|
|
begin
|
|
Log('Found and removing PATH entry: ' + PathList[I]);
|
|
PathList.Delete(I);
|
|
end;
|
|
end;
|
|
|
|
// Reconstruct the PATH
|
|
NewPath := PathList.DelimitedText;
|
|
|
|
// Write the new PATH back to the registry
|
|
if RegWriteExpandStringValue(HKEY_LOCAL_MACHINE,
|
|
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
|
|
'Path', NewPath)
|
|
then
|
|
Log('Successfully removed path entry: ' + PathToRemove)
|
|
else
|
|
Log('Failed to write modified PATH to registry');
|
|
finally
|
|
PathList.Free;
|
|
end;
|
|
end;
|
|
|
|
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
|
|
var
|
|
AppPath: string;
|
|
begin
|
|
if CurUninstallStep = usUninstall then
|
|
begin
|
|
// Get the application installation path
|
|
AppPath := ExpandConstant('{app}');
|
|
Log('Removing PATH entry for: ' + AppPath);
|
|
|
|
// Remove only our path entry from the system PATH
|
|
RemovePathEntry(AppPath);
|
|
end;
|
|
end; |