Skip to content

Commit

Permalink
Merge pull request #2065 from HullSeals/fix/installer-old-versions-guid
Browse files Browse the repository at this point in the history
Cleanup Old Installers Logic
LGTM
  • Loading branch information
C1701D authored Aug 22, 2023
2 parents 6e8f881 + 688cb1b commit 949a352
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
Binary file modified modules.p
Binary file not shown.
40 changes: 32 additions & 8 deletions resources/EDMC_Installer_Config_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 | where Name -eq ''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
Expand All @@ -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}"

0 comments on commit 949a352

Please sign in to comment.