- NSIS Discussion
- batch file execution
Archive: batch file execution
Anselmus
28th September 2006 12:22 UTC
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
Afrow UK
28th September 2006 12:25 UTC
nsExec::Exec '"$EXEDIR\BATCH.bat" "params"'
-Stu
Takhir
28th September 2006 13:06 UTC
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).
Anselmus
28th September 2006 13:48 UTC
thanks for the fast reply. i tried it the way Afrow UK suggested. still it won't work... =(
Anselmus
28th September 2006 14:25 UTC
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...
kichik
29th September 2006 12:40 UTC
Use SetOutPath to set the working directory.
Anselmus
4th October 2006 15:57 UTC
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
Anselmus
4th October 2006 16:26 UTC
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
Mr Inches
5th October 2006 12:00 UTC
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
Anselmus
5th October 2006 12:11 UTC
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
aceld
17th April 2008 20:14 UTC
I was stuck at the same situation, and your solution saved my life!