I'm trying to put together a simple Inno Setup installer which looks for the previous version and removes it before proceeding. Everything is working fine until I get the following code:
if Exec(UninstallString, '/SILENT', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('Previous version found and uninstalled successfully.', mbInformation, MB_OK);
end
else
begin
MsgBox('Please uninstall the previous version of this mod before continuing.', mbInformation, MB_OK);
Result := FALSE;
end;
It's a very simple bit of code, but it ALWAYS fails. I've checked the contents of UninstallString
and they're correct (C:\Windows\unins000.exe
) but the Exec fails with the error: "The directory name is invalid."
It appears that it can't read the contents of "UninstallString" correctly, because if I enter them manually (e.g. Exec('C:\Windows\unins000.exe, ...
) it works fine.
How can I make Exec
process the string "UninstallString" as intended?