执行批处理文件NSIS安装 [英] Executing Batch File in NSIS installer
问题描述
我有我需要我的NSIS安装中运行的批处理文件。所有文件解压后,必须运行,(我想这是很明显的,否则该批处理文件将尚不存在)。
I have a batch file that I need to run within my NSIS installer. It must run after all the files have been extracted, (I suppose this is obvious, otherwise the batch file wouldn't exist yet).
我试图用MUI_PAGE_CUSTOMFUNCTION_ pre与完成页面才能运行,但是当它到达剧本的那部分看来,它跳过就在这。下面是我如何调用它。
I tried to use MUI_PAGE_CUSTOMFUNCTION_PRE with the finish page in order to run it but when it gets to that portion of the script it appears that it skips right over it. Below is how I invoke it.
;;Finish Page
!define MUI_PAGE_CUSTOMFUNCTION_PRE Done
!insertmacro MUI_PAGE_FINISH
Function Done
ExecWait '"$INSTDIR\BatchFile" "$INSTDIR" "$DATA_FOLDER"'
FunctionEnd
在此先感谢您的帮助。
Thanks in advance for your help.
更新的
UPDATE
我现在已经使用以下尝试:
I have now tried using the following:
ExpandEnvStrings $0 %COMSPEC%
ExecWait '"$0" /C "$INSTDIR\batch.bat" "$INSTDIR" "$DATA_FOLDER"'
这没有工作,所以我拿出/ C看到的命令提示符说的话(这是雨后春笋般冒出来,但马上关闭),它好像它执行cmd.exe的,但仅此而已,这不是' ŧ完成的执行的其余部分。
This did not work, so I took out the /C to see what the cmd prompt was saying (it is popping up, but closing immediately) and it seems as though it executes cmd.exe but that's it, it doesn't complete the rest of the execute.
更新#2 的
UPDATE #2
核心知识,导致我得到它的工作可以在这里找到:
The core knowledge that led to me getting it to work can be found here:
<一个href=\"http://stackoverflow.com/questions/148968/windows-batch-files-bat-vs-cmd\">http://stackoverflow.com/questions/148968/windows-batch-files-bat-vs-cmd
无论出于何种原因.bat文件不同意ExecWait
For whatever reason .bat files do not agree with ExecWait.
在结束:
ExecWait '"$INSTDIR\BatchFile.cmd" "$INSTDIR" "$DATA_FOLDER"'
工作就好了。
推荐答案
执行[等待]需要适当报价:
Exec[Wait] needs proper quoting:
ExpandEnvStrings $0 %COMSPEC%
ExecWait '"$0" /C "c:\path\to\batch.cmd" "quoted param" normalparam "c:\last param"'
这篇关于执行批处理文件NSIS安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!