Execute Command-Line Command from NSIS

Viewed 33640

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 begin and other similar topics have gone a little over my head.

3 Answers

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.

Related