Skip to content
⌘ NSIS Forum Archive

nsExec in No wait mode?

8 posts

SJSJ#

nsExec in No wait mode?

Hello,

Is there a way to run a batch file without showing the command prompt window AND where the command doesn't wait for the batch file to complete execution (ie, NO WAIT mode)?

I have been using nsExec::Exec and nsExec::ExecToLog to run batch files and exe, but I believe in all nsExec commands, it waits for the exe/batch to complete and return.

In this particular case, I wish to execute the batch in silent mode and wish to continue with installation without waiting for it to return. Can I use nsExec in someway in this case?

Any help in this will be appreciated! Thanks!!

-SJ
SJSJ#
Have been trying the ExecDos plugin, but never quite get it right I guess.

This is how I am calling it:

ExecDos::exec /NOUNLOAD /ASYNC '"$INSTDIR\my.bat" "$INSTDIR\abc.txt"'

where $INSTDIR\my.bat is the batch file and $INSTDIR\abc.txt is an input.

The problem I face right now is the batch file starts executing and stops mid way. Is there a time out? I read that the default time out is huge.
So I wonder what is causing the batch to start and stop abruptly.
Anders#
!include LogicLib.nsh
section
ExpandEnvStrings $0 "%COMSPEC%"
StrCpy $1 '"$0" /C if 1==1 "$instdir\testbatch.cmd" "$INSTDIR\abc.txt" param2 "param 3" param4'
DetailPrint Exec=$1
System::Call `KERNEL32::WinExec(tr1,i0)i.r0`
${If} $0 > 32
    DetailPrint "OK"
${Else}
    DetailPrint "Error"
${EndIf}
sectionend 
SJSJ#
Hi Anders,

I get an Error displayed.
What does that mean? I had tried setting the COMSPEC and executing with /c for Exec and it had stopped mid way too.
Anders#
There is a off by one error there, it should be > 31 or >= 32.
If you don't care about the error code you can just do
ExpandEnvStrings $0 "%COMSPEC%"
ExecShell "" '"$0"' '/C if 1==1 "$instdir\testbatch.cmd" "$INSTDIR\abc.txt" param2 "param 3" param4' SW_HIDE