diff --git a/modules.p b/modules.p index 5d7adf41..c48f76c4 100644 Binary files a/modules.p and b/modules.p differ diff --git a/resources/EDMC_Installer_Config_template.txt b/resources/EDMC_Installer_Config_template.txt index 4b8f053d..f873eb2c 100644 --- a/resources/EDMC_Installer_Config_template.txt +++ b/resources/EDMC_Installer_Config_template.txt @@ -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"