【问题标题】:Executing Bat File in NSIS installer-not working在 NSIS 安装程序中执行 Bat 文件 - 不工作
【发布时间】:2012-10-17 12:53:54
【问题描述】:

我已经为我的 java 项目成功构建了 nsis 脚本。我需要在我的 NSIS 安装程序中运行一个批处理文件。它必须在提取所有文件后运行。我尝试了以下命令

!define MUI_FINISHPAGE_RUN $INSTDIR\bin\batch.bat

这个也试过了:

SetOutPath $INSTDIR
ExpandEnvStrings $0 %COMSPEC%
nsExec::ExecToStack '"$INSTDIR\batch.bat"'

我已经提到了这个link

我的要求是:

1.安装完成后如何使用Nsis脚本启动批处理文件?

【问题讨论】:

    标签: nsis


    【解决方案1】:

    如果您不打算使用结果,为什么要调用 ExpandEnvStrings?您的两个示例中的路径甚至都不匹配。

    只要路径和引号正确,它应该可以工作:

    !include MUI2.nsh
    !insertmacro MUI_PAGE_INSTFILES
    !define MUI_FINISHPAGE_RUN
    !define MUI_FINISHPAGE_RUN_FUNCTION RunBatch
    !insertmacro MUI_PAGE_FINISH
    !insertmacro MUI_LANGUAGE English
    
    Function RunBatch
    ;The most basic version, runs with visible console:
    ExecWait '"$temp\test.cmd" /foo "bar baz" /blergh'
    
    ;You must use cmd.exe if you want redirection (With stupid extra quotes for cmd.exe):
    ExpandEnvStrings $0 %COMSPEC%
    ExecWait '"$0" /C ""$temp\test.cmd" /foo "bar baz" /blergh > "$temp\stdout.txt""'
    
    ;Use one of the exec plugins if you want to hide the console:
    nsExec::Exec '"$temp\test.cmd" /foo "bar baz" /blergh'
    FunctionEnd
    

    您可以根据需要使用几个 exec 插件:nsExecExecDosExecCmd

    【讨论】:

    • 谢谢。什么是“test.cmd”?你在 ExecWait 命令中提到过吗?
    猜你喜欢
    • 2011-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 2011-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多