79520207

Date: 2025-03-19 12:39:18
Score: 1
Natty:
Report link

I have finally figured out to how to solve what I wanted.
I post this here as it might help someone else in the same situation.
I now install the program with "administrative install mode", but the old software is uninstalled as the logged in user, if that user has previously installed the old software.

[Code]
function PrepareToInstall(var NeedsRestart: Boolean): string;
var
  OldAppGuid, SubKeyName: string;
  OldAppFound: Boolean;
  ResultCode: Integer;
begin
  NeedsRestart := false;
  result := '';
  begin
    OldAppGuid := '{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}';
    SubKeyName := 'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\' + OldAppGuid;
    OldAppFound := RegKeyExists(HKEY_LOCAL_MACHINE, SubKeyName);
    if not OldAppFound then
    begin
      SubKeyName := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + OldAppGuid;
      OldAppFound := RegKeyExists(HKEY_LOCAL_MACHINE, SubKeyName);
    end;
    if OldAppFound then
    begin
      ExecAsOriginalUser(ExpandConstant('{sys}\msiexec.exe'),  // Filename
        '/X ' + OldAppGuid + ' /qb- REBOOT=ReallySuppress',    // Params
        '',                                                    // WorkingDir
        SW_SHOW,                                               // ShowCmd
        ewWaitUntilTerminated,                                 // Wait
        ResultCode);                                           // ResultCode
    end;  
  end;
end;
Reasons:
  • Blacklisted phrase (1): how to solve
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Nalle077