简体   繁体   English

如何在installshield安装程序中运行/包含批处理文件

[英]How to run/include batch file in installshield setup

I have created setup using installshield and everything is work file. 我使用installshield创建了安装程序,一切都是工作文件。 Now I have one batch file and want to run with setup. 现在我有一个批处理文件,想要使用安装程序运行。 I know we can create custom action and I have already created custom action for run powershell script and it is working fine. 我知道我们可以创建自定义操作,并且我已经为运行PowerShell脚本创建了自定义操作,它运行正常。

Can anyone help/guide me for using which custom action I can execute the batch file? 任何人都可以帮助/指导我使用哪些自定义操作我可以执行批处理文件?

Also I want to run MySQL script from installshield setup. 我还想从installshield setup运行MySQL脚本。

What I have tried: 我尝试过的:

I have tried to create different custom action but I don't know exactly which custom action is used for execute the batch file. 我试图创建不同的自定义操作,但我不知道确切地使用哪个自定义操作来执行批处理文件。

ASSUMING AN MSI INSTALLATION: 假设MSI安装:

In your MSI Installation Designer pane, click on "Custom Actions and Sequences"; 在“MSI安装设计器”窗格中,单击“自定义操作和序列”; in the top part of the middle pane right click on "Custom Actions" and choose "New EXE -> Stored in Binary Table". 在中间窗格的顶部右键单击“自定义操作”,然后选择“新建EXE - >存储在二进制表中”。 Give it a name (and description, if you like). 给它一个名字(和描述,如果你愿意)。 When it saves, right-click it and start the Custom Action Wizard. 保存时,右键单击它并启动自定义操作向导。

The Action Type should be "Launch an executable" and the Location should be "Stored in the Directory Table". 操作类型应为“启动可执行文件”,并且“位置”应“存储在目录表中”。

For Action Parameters "Source", choose the directory you want to start in. For target enter a command to invoke your script, like cmd /c .\\RunMyScript.bat arg1 arg2 ... (assuming the script is in the directory you started in.) If the script is in a different folder you can put one of your directory variables in brackets: cmd /c [INSTALLDIR]bin\\script.bat . 对于Action Parameters“Source”,选择要启动的目录。对于target,输入一个命令来调用脚本,例如cmd /c .\\RunMyScript.bat arg1 arg2 ... (假设脚本位于您启动的目录中如果脚本位于不同的文件夹中,您可以将一个目录变量放在括号中: cmd /c [INSTALLDIR]bin\\script.bat Typically the directory variable will already include a trailing backslash; 通常,目录变量已经包含一个尾部反斜杠; using these variables with the bracket syntax helps make sure the action works even if the user chooses a different installation folder. 将这些变量与括号语法一起使用有助于确保即使用户选择其他安装文件夹,该操作仍然有效。

If the script is in a folder that is not a required part of the installation, you may need to make your command be something like cmd /c if exist .\\script.bat .\\script.bat - so that the custom action does not fail if the feature containing your script is not selected for install (or is removed when an installation is modified.) 如果脚本位于不是安装所需部分的文件夹中,则可能需要将命令设置为cmd /c if exist .\\script.bat .\\script.bat - 以便自定义操作不会如果未选择包含脚本的功能进行安装(或在修改安装时删除),则会失败。

I have typically wanted execution to be synchronous (install waits until script finishes before moving on); 我通常希望执行是同步的(安装等待脚本完成后再继续); if your script does not return a reliable exit code, or if you don't want the installation to abort if the script fails, choose the one with "(Ignores error code)". 如果脚本未返回可靠的退出代码,或者如果脚本失败则不希望安装中止,请选择带有“(忽略错误代码)”的脚本。

The custom action should typically be in the InstallExec sequence, after files are installed (but a script you run during an uninstall or repair could run earlier or in a different sequence.) 安装文件后,自定义操作通常应该是InstallExec序列(但是在卸载或修复期间运行的脚本可以更早或以不同的顺序运行。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM