SJSJ
19th October 2011 11:14 UTC
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
MSG
19th October 2011 11:38 UTC
You can use the ExecDos plugin for this.
SJSJ
29th October 2011 08:43 UTC
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
30th October 2011 08:26 UTC
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
31st October 2011 04:45 UTC
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.
SJSJ
31st October 2011 05:53 UTC
Return value is 0.
MSDN says 0 : The system is out of memory or resources.
I am confused :(
Anders
31st October 2011 20:42 UTC
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
SJSJ
2nd November 2011 09:04 UTC
Thanks a lot, Anders!
That worked :up: