Old 19th October 2011, 10:14   #1
SJSJ
Junior Member
 
Join Date: May 2011
Posts: 25
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 is offline   Reply With Quote
Old 19th October 2011, 10:38   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
You can use the ExecDos plugin for this.
MSG is offline   Reply With Quote
Old 29th October 2011, 07:43   #3
SJSJ
Junior Member
 
Join Date: May 2011
Posts: 25
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.
SJSJ is offline   Reply With Quote
Old 30th October 2011, 06:26   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,593
PHP Code:
!include LogicLib.nsh
section
ExpandEnvStrings 
$"%COMSPEC%"
StrCpy $'"$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} $
32
    DetailPrint 
"OK"
${Else}
    
DetailPrint "Error"
${EndIf}
sectionend 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 31st October 2011, 02:45   #5
SJSJ
Junior Member
 
Join Date: May 2011
Posts: 25
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 is offline   Reply With Quote
Old 31st October 2011, 03:53   #6
SJSJ
Junior Member
 
Join Date: May 2011
Posts: 25
Return value is 0.
MSDN says 0 : The system is out of memory or resources.
I am confused
SJSJ is offline   Reply With Quote
Old 31st October 2011, 18:42   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,593
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
code:
ExpandEnvStrings $0 "%COMSPEC%"
ExecShell "" '"$0"' '/C if 1==1 "$instdir\testbatch.cmd" "$INSTDIR\abc.txt" param2 "param 3" param4' SW_HIDE


IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd November 2011, 07:04   #8
SJSJ
Junior Member
 
Join Date: May 2011
Posts: 25
Lightbulb

Thanks a lot, Anders!
That worked
SJSJ is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump