I tried to uninstall previous version which installed by InstallShield.
function GetUninstallString(): String;
var
sUnInstPath: String;
sUnInstallString: String;
begin
sUnInstPath := ExpandConstant('SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{OldAppID}');
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString)then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
MsgBox(sUnInstallString, mbInformation, MB_OK);
Result := sUnInstallString;
end;
function UninstallOldVersion(): Integer;
var
sUnInstallString: String;
iResultCode: Integer;
begin
// Returb Values:
// 1 - uninstall string is empty
// 2 - error executing the UnInstallString
// 3 - successfully executed the UnInstalString
//default return value
Result := 0;
//get the uninstall string of the old app
sUnInstallString := GetUninstallString();
if sUnInstallString <> '' then begin
sUnInstallString:= RemoveQuotes(sUnInstallString);
if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES', '', SW_HIDE, ewWaitUntilTerminated, iResultCode) then begin
Result := 3
MsgBox('3', mbInformation, MB_OK);
end
else begin
Result := 2
MsgBox('2', mbInformation, MB_OK);
end;
end else begin
Result := 1
MsgBox('1', mbInformation, MB_OK);
end;
end;
The result of UninstallOldVersion() is '3' but the old version didn't uninstall actually.
The result of GetUninstallString():
"C:\Program Files (x86)\InstallShield Installation Information\{OldAppID}\setup.exe" -runfromtemp -l0x0409 -removeonly