bat nsis 无法执行_执行批处理文件NSIS安装

bd96500e110b49cbb3cd949968f18be7.png

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).

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"'

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.

UPDATE #2

The core knowledge that led to me getting it to work can be found here:

For whatever reason .bat files do not agree with ExecWait.

In the end:

ExecWait '"$INSTDIR\BatchFile.cmd" "$INSTDIR" "$DATA_FOLDER"'

Worked just fine.

解决方案

Exec[Wait] needs proper quoting:

ExpandEnvStrings $0 %COMSPEC%

ExecWait '"$0" /C "c:\path\to\batch.cmd" "quoted param" normalparam "c:\last param"'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值