installation - 在 Inno Setup 中执行 UninstallString

标签 installation inno-setup uninstallation uninstallstring

我的要求是在安装之前检查以前安装的 SQL Native Client 11 并卸载以前的版本。我可以检查以前的安装,没有任何问题,但是,我无法卸载它。

我使用了How to detect old installation and offer removal?中提到的解决方案

在运行时,我收到以下错误

Exception: Internal error: Unknown constant "A22EED3F-6DB6-4987-8023-6C6B7030E554".

(其中常量是 native 客户端的 GUID)在该行执行期间

Exec(ExpandConstant(sUnInstallString), '', '', SW_SHOW, ewWaitUntilTerminated, iResultCode);

sUnInstallString

MsiExec.exe /I{A22EED3F-6DB6-4987-8023-6C6B7030E554}

提前致谢。

最佳答案

这不是 (Inno Setup) 常量。那是一个 GUID。删除 ExpandConstant 调用。

并且您需要将卸载字符串拆分为程序路径及其参数。

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;

关于installation - 在 Inno Setup 中执行 UninstallString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42222356/

相关文章:

java - 软件安装自动化

Ubuntu 10.04 开发工具

mysql - 不小心卸载了mysql服务器

python - virtualenv:在 macOS 上卸载并重新安装

windows - 如果Windows批处理文件超过一分钟,请立即退出循环

node.js - 可以在离线的内网环境下使用Cordova吗?

windows - cabal 安装 glib 出错

非 Unicode Inno Setup 中的 C# 字符串

inno-setup - Inno Setup - 如何在安装过程中读取 INF 文件

dll - Inno Setup 6 不能使用带字符串参数的 DLL 函数,但它在 Inno Setup 5 中有效