Execute Command-Line Command from NSIS

前端 未结 3 1221
梦如初夏
梦如初夏 2021-02-07 08:28

I\'m creating my first NSI script and I\'m just wondering if I can execute a command-line command from NSIS or should I just execute a batch file? I don\'t really know where to

3条回答
  •  无人及你
    2021-02-07 09:17

    We can launch a command-line command from NSIS, get the returned value and further develop the installation logic based on that.

    Example: Let's say we need to get the installed clang compiler version. To get the version we have to launch:

    clang --version 
    

    In NSIS we do this using ExecToStack:

         nsExec::ExecToStack  'cmd /c "clang --version"'
         Pop $0
         Pop $0
         ;now we have the version in $0
    

    Warning: Only the second Pop $0 gets the response that we want, in this case the clang version. The first Pop $0 grabs the exit code.

提交回复
热议问题