如何在使用 Inno Setup 设置之前运行文件

Posted

技术标签:

【中文标题】如何在使用 Inno Setup 设置之前运行文件【英文标题】:How to run a file before setup with Inno Setup 【发布时间】:2011-03-30 10:27:09 【问题描述】:

是否可以在设置开始之前使用 Inno Setup 运行文件? Documentation

【问题讨论】:

【参考方案1】:

是的。在[code] 部分运行InitializeSetup() 函数中的文件。此示例在安装程序运行之前启动记事本。

function InitializeSetup(): boolean;
var
  ResultCode: integer;
begin

  // Launch Notepad and wait for it to terminate
  if Exec(ExpandConstant('win\notepad.exe'), '', '', SW_SHOW,
     ewWaitUntilTerminated, ResultCode) then
  begin
    // handle success if necessary; ResultCode contains the exit code
  end
  else begin
    // handle failure if necessary; ResultCode contains the error code
  end;

  // Proceed Setup
  Result := True;

end;

【讨论】:

这就是我需要的!谢谢。 如果它更改了用户计算机上的任何内容,则不应在 InitializeSetup 中执行此操作。这应该在用户按下“安装”后完成,即 PrepareToInstall() 或 CurStepChanged(ssInstall)。

以上是关于如何在使用 Inno Setup 设置之前运行文件的主要内容,如果未能解决你的问题,请参考以下文章