在 Inno Setup 中的 [Files] 部分之前执行批处理文件
目前我的批处理文件位于 [Run]
部分。我需要在 [Files]
部分之前执行批处理文件。有没有办法在 Inno Setup 中做到这一点?目前,[Run]
部分始终在 [Files]
部分之后执行。
[Run]
Filename: "C:\Users\Scripts\Install\Install.bat"; \
Parameters: {code:GetDatabaseName}
[Files]
Source: "C:\Users\MyApp\*"; DestDir: "\\MyServer\MyApp"; \
Flags: recursesubdirs createallsubdirs
Currently my batch file is in [Run]
section. I need my batch file to execute before the [Files]
section. Is there a way to do this in Inno Setup? Currently the [Run]
section always execute after [Files]
section.
[Run]
Filename: "C:\Users\Scripts\Install\Install.bat"; \
Parameters: {code:GetDatabaseName}
[Files]
Source: "C:\Users\MyApp\*"; DestDir: "\\MyServer\MyApp"; \
Flags: recursesubdirs createallsubdirs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果需要在安装开始时完成,请在
PrepareToInstall()
或CurStepChanged(ssInstall)
事件函数中使用Exec()
。这些都是在用户说“继续,安装”之后但在其他任何事情之前。
PrepareToInstall()
还允许您取消安装并发出警告。如果需要先从安装程序中提取文件,那么您可以在其前面使用
ExtractTemporaryFile()
If it needs to be done at the beginning of the setup, use
Exec()
in thePrepareToInstall()
orCurStepChanged(ssInstall)
event functions.These are both after the user has said "go ahead, install" but before anything else.
PrepareToInstall()
also allows you to cancel the install with a nice warning.If the file needs to be extracted from the setup first, then you can preceed it with
ExtractTemporaryFile()
继续 Deanna 的精彩答案,代码示例:
此代码始终返回一个空字符串,它告诉设置继续。
如果您想停止安装(在某些错误情况下),您需要返回一个非空字符串,它将显示给用户(并且安装将停止)。
为了返回错误字符串,请在PrepareToInstall中添加以下行:
Continuing Deanna's great answer, code example:
this code always returns an empty string, which tells the setup to continue.
In case you want to stop setup (in some error cases) you need to return a non empty string and it will be displayed to the user (and setup will be stopped).
In order to return an error string add this line in PrepareToInstall's:
您可以使用
InitializeSetup
事件 + 一些 pascal 脚本。看; 如何在使用 Inno Setup 进行设置之前运行文件
该示例中未提及;要从安装程序获取文件,您可以使用
ExtractTemporaryFile('your.bat')
然后使用Exec(ExpandConstant('{tmp}\your.bat ...
) 运行它。You can use the
InitializeSetup
event + some pascal scripting.See; How to run a file before setup with Inno Setup
Not mentioned in that example; to get the file from the installer you would use
ExtractTemporaryFile('your.bat')
thenExec(ExpandConstant('{tmp}\your.bat ...
to run it.