2

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 Answer 1

4

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.