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?
stringtype variable with the same value as the constant. The problem must be somewhere else. Don't you useAnsiStringtype e.g. for theUninstallStringvariable, don't you ? - TLamaUninstallString: string;is that wrong? And, I promise you, the contents are there. I just checked again. It's boggling my mind. - Chuck Le ButtExecfunction point of view) absolutely no difference between that constant and the variable having the same value as the constant. I'm starting to think about some non-printable char in that registry value... How did you check theUninstallStringvalue ? - TLama