3

Situation is, i have 3 separate batch files in different locations running start commands on .jar .exe and call command to open index.html through Firefox.

I want to create one global batch-file to run all of these one at a time. Extra hint would be to make a pause (several seconds) in between calling each one of those commands.

These are the commands i am executing in batch files:

echo majmun1
call C:\OKOLINA\additionConsoleApplication1.exe
echo majmun2
call C:\OKOLINA\addition1\jWebSocketSamples-2.0.jar
echo majmun3
call firefox.exe C:\OKOLINA\addition2\index.html
echo majmun4
exit

It only executes call the first one and stops.

1
  • I'm pretty sure call waits for the process to end.
    – Monacraft
    Commented Nov 8, 2013 at 1:32

2 Answers 2

6

You need to use start istead:

echo majmun1
start C:\OKOLINA\additionConsoleApplication1.exe
echo majmun2
start C:\OKOLINA\addition1\jWebSocketSamples-2.0.jar
echo majmun3
start firefox.exe C:\OKOLINA\addition2\index.html
echo majmun4
exit

If you want to make a pause between starts, then you can use this little hack:

command 1
ping -w 1000 -n 5 127.0.0.1
command 2

It pings localhost 5 times (-n 5) and waits 1000ms (-w 1000) between each ping, effectively delaying execution of command 2 for 5 seconds. (You can't use pause as it waits for a user to press Enter and there is no built-in delay command).

1
  • this was crucial for getting it to run from C#, I had a batch that just called java.exe, and it would always hang until my unit test finished, adding start to the front of the call fixed it, thanks!!
    – mhand
    Commented Jan 24, 2015 at 16:10
1

Use start instead of call to launch your applications.

call calls one batch program from another (The filename parameter must have a .bat or .cmd extension).

On the other hand, start starts a separate command prompt window to run a specified program or command.

Not the answer you're looking for? Browse other questions tagged or ask your own question.