Skip to content
⌘ NSIS Forum Archive

ExecWait and .bat vs .cmd

4 posts

nedloh#

ExecWait and .bat vs .cmd

This is a question more than a problem, but I was working on my NSIS script and during the install process I had a batch file that I needed to run. I attempted to use ExecWait to execute it but it would not run the .bat file and for the life of me could not figure it out. I spent an entire day at work attempting to fix the problem.

The solution I found at the end of the day is to save the batch file with the .cmd extensions. After hours of fiddling it turned out that doing this and then calling the same way I did when I started my journey solved the problem.

Does anyone have an explanation on this?
Afrow UK#
You should never run a batch file using ExecWait without cmd.exe. A batch file is not an executable; it is just another file type associated to run with cmd.exe. In addition, don't use ExecWait because you'll get an ugly console window popup. Use nsExec or ExecDos:

ReadEnvStr $R0 COMSPEC
ExecDos::Exec `"$R0" /C "some_batch_file.bat"`
Pop $R0

Stu
nedloh#
Possibly the ExecDos would fix it however I did make sure to run it with cmd.exe as in your example with ExecWait and it did not work at all. As I said I did a simple

ExecWait '"Batch.cmd" "param1" "param2"'

and it worked just fine.