1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-12 23:37:14 +03:00

[Installer] Old Ver Removal with Diff GUID

This commit is contained in:
David Sangrey 2023-08-17 23:15:33 -04:00
parent 6e8f8815df
commit 7894753d2e
No known key found for this signature in database
GPG Key ID: 3AEADBB0186884BC
2 changed files with 32 additions and 8 deletions

BIN
modules.p

Binary file not shown.

View File

@ -54,27 +54,48 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang
;Check if a WiX-based installation exists. If so, kill it with fire.
[Code]
function IsWixInstalled: Boolean;
function EndsWith(SubText, Text: AnsiString): Boolean;
var
Uninstall: String;
EndStr: string;
begin
Result := RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5E9AD4D3-0365-41D5-9586-9368745DD109}', 'UninstallString', Uninstall);
Log('Starting');
EndStr := Copy(Text, Length(Text) - Length(SubText) + 1, Length(SubText));
Log(EndStr);
{ Use SameStr, if you need a case-sensitive comparison }
Result := SameText(SubText, EndStr);
end;
// EDMC didn't keep a consistant GUID during previous history. Due to that, we have to do this tomfoolery.
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
Uninstall: String;
OldWiX: Boolean;
S: AnsiString;
PowerShellOutputFile: String;
begin
if (CurStep = ssInstall) and IsWixInstalled then
if (CurStep = ssInstall) then
begin
MsgBox('Warning: an old version of EDMC is installed! Please close EDMC while we remove the old version!', mbInformation, MB_OK);
Uninstall := '/x {5E9AD4D3-0365-41D5-9586-9368745DD109}';
Exec('MsiExec.exe', Uninstall, '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
PowerShellOutputFile := ExpandConstant('{tmp}\PowershellOutput.txt');
// Construct the PowerShell command and capture output to a file
Exec('powershell.exe', '-NoProfile -ExecutionPolicy Bypass -Command "Get-WmiObject -Class Win32_Product | ForEach-Object { $_.Name -like ''*Elite Dangerous Market Connector*'' } | Select-Object -ExpandProperty IdentifyingNumber" | Out-File -Encoding ASCII "' + PowerShellOutputFile + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
begin
if LoadStringFromFile(PowerShellOutputFile, S) then
S:= Trim(S);
Log(S);
begin
OldWiX:=EndsWith('}', S);
if (OldWiX = True) then
begin
MsgBox('Warning: an old version of EDMC is installed! Please close EDMC while we remove the old version!', mbInformation, MB_OK);
Uninstall := '/x ' + S;
Exec('MsiExec.exe', Uninstall, '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
end;
end;
end;
end;
[Registry]
; Create the main registry key under HKCR
Root: HKCR; Subkey: "edmc"; Flags: uninsdeletekey
@ -92,3 +113,6 @@ Root: HKCR; Subkey: "edmc\shell\open"; Flags: uninsdeletekey
Root: HKCR; Subkey: "edmc\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\EDMarketConnector.exe"" ""%1"""; Flags: uninsdeletekey
; Create the "ddeexec" subkey under the "open" subkey
Root: HKCR; Subkey: "edmc\shell\open\ddeexec"; ValueType: string; ValueName: ""; ValueData: "Open(""%1"")"; Flags: uninsdeletekey
[InstallDelete]
Type: filesandordirs; Name: "{app}/plugins"