Archive: batch file execution


batch file execution
hi folks,

i'm new to nsis and desperatly trying to get my script running for the whole morning now.

i'm trying to run a batch file with one parameter (\service.bat install).

i tried ExecWait and ExecShell and every possible combination of quotation marks.

i even created a new batchfile with no parameter to call the first one from within this second batch file. still it won't work. dos-box comes up for a few milliseconds and disappears.

can someone help me out with thatone?

thanks
stephan


nsExec::Exec '"$EXEDIR\BATCH.bat" "params"'

-Stu


Console window means file found by system and started. Add Pause to you bat after every line to see output or use output redirection. ExecWait is better for debugging, but finally use nsExec (hides console).


thanks for the fast reply. i tried it the way Afrow UK suggested. still it won't work... =(


somehow there seems to be a problem with executing the second batch file i created (set_service.bat) which looks like this:

@echo off
CALL service.bat install
ECHO end of set_service.bat
PAUSE


if i execute it manually (command line) or execute it by doubleclicking it works fine

but with the the ExecWait Command it wont do it outputs that it cannot find service.bat, even though they are in the same directory...


Use SetOutPath to set the working directory.


i tried this:


SetOutPath "$INSTDIR\AgroKONNEKTOR\bin"
nsExec::Exec '"COMMAND" "$SYSDIR /Y /K $INSTDIR\AgroKONNEKTOR\bin\set_service.bat"'


and a lot of different versions, yet it wont run.

gtx
anselmus


cant anyone help me out with this? i'm getting mad on this one... :(

to make my problem a beit clearer: i'm trying to run the service installer delivered with tomcat 5.5.17 (bin\service.bat) which requires to be run as: "service install" or "service.bat install"

any suggestions are most welcome


The command you are trying to run is no good. :(

Try this code:

SetOutPath "$INSTDIR\AgroKONNEKTOR\bin"
nsExec::Exec "CMD" "/C $INSTDIR\AgroKONNEKTOR\bin\set_service.bat"

The /C switch means 'run the following program under the new command shell, then exit the command shell and return to the program that launched you when it completes'.

The /K switch means 'run the following program under the new command shell and then leave the command shell running after it completes until it is manually exited by typing "exit"' - (K)eep.

There is no /Y switch supported by CMD.EXE or COMMAND.COM.

Duncan


hi duncan,

thanks for the reply, but it does not work. dont ask my why.

but i seem to have solved tho problem in a different way. now, i let nsis create the batch file instead of having a static batch file: it looks like this:

SetOutPath "$INSTDIR\AgroKONNEKTOR\bin"
StrCpy "$1" "$INSTDIR"
StrCpy $1 $1 2
MessageBox MB_OK "$1"
FileOpen "$0" "set_service.bat" "w"
;FileWrite "$0" "@ECHO OFF$\r$\n"
FileWrite "$0" "$1$\r$\n"
FileWrite "$0" "cd $INSTDIR\AgroKONNEKTOR\bin$\r$\n"
FileWrite "$0" "CALL service install$\r$\n"
;FileWrite "$0" "pause"
FileClose "$0"
MessageBox MB_OK "wrote setter"
ExecWait "set_service.bat"


the message boxes and pause command are for debugging purposes


I was stuck at the same situation, and your solution saved my life!