如何使用 Inno Setup 取消安装程序?

发布于 2024-07-21 05:28:45 字数 639 浏览 9 评论 0原文

我正在使用 Inno setup 来安装我的产品,在安装中我执行一个外部程序 (Validator.exe),如果该程序被取消或中止,我必须取消我自己的安装程序。

我将 Validator.exe 保存在 {app} 路径中并执行它。

当安装程序运行时,我调用 Validator.exe 文件,并通过以下方式获得执行结果: Exec(ExpandConstant('{app}/Validator.exe'), '', '', SW_SHOW, ewWaitUntilTermulated, ResultCode).

但这是我尝试过的所有解决方案的问题:

InitializeSetup:Validator.exe 文件尚未复制到 {app} 中,因此它永远不会被执行。

Abort:只能在 (InitializeSetup,InitializeWizard,CurStepChanged(ssInstall)) 中调用,因此在这些情况下,验证器尚未复制。

DeinitializeSetup:我可以在安装后执行 Validator.exe,但此时无法中止我的安装程序。

在复制并执行 Validator.exe 后,我需要某种方法来取消安装,也许可以调用卸载,但我无法做到这一点。

谢谢你的帮助。

I am using Inno setup to install a product of mine, in the setup I execute an extern program (Validator.exe) if this program is canceled or aborted I have to cancell my own installer.

I save the Validator.exe in {app} path and the execute it.

When the installer is running I call Validator.exe file and I get the result of the execution with:
Exec(ExpandConstant('{app}/Validator.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode).

But this are the problems with all the solutions that I have tried:

InitializeSetup: The Validator.exe File is not copied in {app} yet, so it will never be executed.

Abort:can be called only in (InitializeSetup,InitializeWizard,CurStepChanged(ssInstall)) so in these cases the Validator is not copied yet.

DeinitializeSetup: I can execute Validator.exe after the installation but I can't abort the my installer from this point.

I need some way to cancel the installation after Validator.exe has been copied and executed, maybe call uninstall but I couldn't do it.

Thanks for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

林空鹿饮溪 2024-07-28 05:28:45

您可以简单地使用 ExtractTemporaryFile() 辅助函数在任何早期安装步骤中提取 validator.exe。 请参阅问题 inno setup extracting文件在启动设置而不是结束 以及我的回答。

You could simply use the ExtractTemporaryFile() helper function to extract validator.exe at any earlier installation step. See the question inno setup extracting files at the start up setup instead of the end and my answer to it.

樱花坊 2024-07-28 05:28:45

谢谢它效果很好。 这就是我修复它的方法:

function InitializeSetup(): Boolean;.
var
  ResultCode : Integer;
begin
  Result := True;
  ExtractTemporaryFile('Validator.exe');

  if Exec(ExpandConstant('{tmp}\Validator.exe'), '', '', SW_SHOW,
    ewWaitUntilTerminated, ResultCode)
  then begin
    if not (ResultCode = 0) then begin
      Result := false;
    end;
  end;
end;

Thanks it works excellent. This is how I fixed it:

function InitializeSetup(): Boolean;.
var
  ResultCode : Integer;
begin
  Result := True;
  ExtractTemporaryFile('Validator.exe');

  if Exec(ExpandConstant('{tmp}\Validator.exe'), '', '', SW_SHOW,
    ewWaitUntilTerminated, ResultCode)
  then begin
    if not (ResultCode = 0) then begin
      Result := false;
    end;
  end;
end;
勿忘初心 2024-07-28 05:28:45

在 Inno Setup 中,“外部”文件是指不包含在安装程序 EXE 文件中的文件。 它存在于外部,可能作为一个单独的文件包含在安装程序 EXE 文件中。 您说在 InitializeSetup 事件中未调用 Abort 的原因是验证程序尚未复制到 {app} 目录,这是可以理解的,因为此时用户尚未指定安装目的地应该是什么。 但您不需要验证器位于目标目录中。 它已经是一个外部文件,因此只需从它所在的任何目录运行它即可。

另一种可能性是将所需的验证功能放入 DLL 中。 您可以将 DLL 包含在安装程序中,Inno Setup 会将 DLL 提取到临时位置,以便您可以从安装脚本调用其函数。

In Inno Setup, an "external" file is one that is not included within the installer EXE file. It exists externally, presumably included as a separate file with the installer EXE file. You say your reason for not calling Abort within the InitializeSetup event is that the validation program hasn't yet been copied to the {app} directory, which is understandable since at that point, the user hasn't yet specified what the installation destination should be. But you don't need the validator be be in the destination directory. It's already an external file, so simply run it from whatever directory it's already in.

Another possibility is to put the required validation functionality into a DLL. You can include the DLL in the installer, and Inno Setup will extract the DLL to a temporary location so that you can call its functions from the install script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文