mirror of
https://github.com/fosrl/olm.git
synced 2026-02-09 06:26:44 +00:00
Co-authored-by: oschwartz10612 <4999704+oschwartz10612@users.noreply.github.com>
Former-commit-id: 1168f5541c
159 lines
6.0 KiB
Plaintext
159 lines
6.0 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;
|
|
P: Integer;
|
|
UpperOrigPath: string;
|
|
UpperPathToRemove: string;
|
|
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;
|
|
|
|
// Prepare for case-insensitive search
|
|
UpperOrigPath := ';' + UpperCase(OrigPath) + ';';
|
|
UpperPathToRemove := ';' + UpperCase(PathToRemove) + ';';
|
|
|
|
// Check if the path exists in PATH
|
|
P := Pos(UpperPathToRemove, UpperOrigPath);
|
|
if P = 0 then
|
|
begin
|
|
// Path not found, nothing to remove
|
|
exit;
|
|
end;
|
|
|
|
// Remove the path entry from OrigPath
|
|
// We need to handle the actual string with proper casing
|
|
NewPath := ';' + OrigPath + ';';
|
|
|
|
// Find and remove the entry (case-insensitive search but preserve original casing in other entries)
|
|
// We search for the pattern in the upper-case version but remove from the original
|
|
Delete(NewPath, P, Length(PathToRemove) + 1); // +1 for the semicolon
|
|
|
|
// Clean up: remove leading and trailing semicolons, and reduce multiple semicolons to one
|
|
while (Length(NewPath) > 0) and (NewPath[1] = ';') do
|
|
Delete(NewPath, 1, 1);
|
|
while (Length(NewPath) > 0) and (NewPath[Length(NewPath)] = ';') do
|
|
Delete(NewPath, Length(NewPath), 1);
|
|
|
|
// Replace multiple semicolons with single semicolon
|
|
while Pos(';;', NewPath) > 0 do
|
|
StringChangeEx(NewPath, ';;', ';', True);
|
|
|
|
// 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');
|
|
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; |