问题
My requirement is to check for previous installation of SQL native Client 11, before installation and uninstall the previous version. I have been able to check for the previous installation with no problems, however, I am unable to uninstall the same.
I used the solution mentioned in the How to detect old installation and offer removal?
During run time, I am getting the following error
Exception: Internal error: Unknown constant "A22EED3F-6DB6-4987-8023-6C6B7030E554".
(where the constant is the GUID of the native client) during the execution of the line
Exec(ExpandConstant(sUnInstallString), '', '', SW_SHOW, ewWaitUntilTerminated, iResultCode);
The sUnInstallString
is
MsiExec.exe /I{A22EED3F-6DB6-4987-8023-6C6B7030E554}
Thanks in advance.
回答1:
That's not a (Inno Setup) constant. That's a GUID. Remove the ExpandConstant
call.
And you need to split the uninstall string to a program path and its parameters.
var
P: Integer;
UninstallPath: string;
UninstallParams: string;
begin
{ ... }
{ In case the program path is quoted, because it contains spaces. }
{ (it's not in your case, but it can be, in general) }
if Copy(sUnInstallString, 1, 1) = '"' then
begin
Delete(sUnInstallString, 1, 1);
P := Pos('"', sUnInstallString);
end
else P := 0;
if P = 0 then
begin
P := Pos(' ', sUnInstallString);
end;
UninstallPath := Copy(sUnInstallString, 1, P - 1);
UninstallParams := TrimLeft(Copy(sUnInstallString, P + 1, Length(sUnInstallString) - P));
Exec(UninstallPath, UninstallParams, '', SW_SHOW, wWaitUntilTerminated, iResultCode);
{ ... }
end;
来源:https://stackoverflow.com/questions/42222356/executing-uninstallstring-in-inno-setup