How to start 2 programs simultaneously in windows command prompt
Asked Answered
A

7

17

I am using Windows 7 64bit

Here is the code snippet I am using to start

@echo off
call "C:\Program Files (x86)\LOLReplay\LOLRecorder.exe"
call "G:\League of Legends\lol.launcher.exe"
exit

But unless I close LOLRecorder.exe it won't start my lol.launcher.exe.... basically I want both running and the cmd prompt exit after they start. Whats wrong here? I checked out another stackoverflow answer Here but it refers to the same method I am using.

EDIT:

With the start command it just starts 2 terminal windows and nothing starts!

@echo off
start "C:\Program Files (x86)\LOLReplay\LOLRecorder.exe"
start "G:\League of Legends\lol.launcher.exe"
exit
Alo answered 27/6, 2011 at 1:0 Comment(0)
B
25

With the start command it just starts 2 terminal windows and nothing starts!

The problem is the quotes (which are unfortunately required, due to the spaces in the paths). The start command doesn't seem to like them.

You can work around this by using the short DOS names for all the directories (and remove quotes), or by specifying the directory separately and quoting it (which the start command seems to be able to deal with).

Try this:

@echo off
start /d "C:\Program Files (x86)\LOLReplay" LOLRecorder.exe
start /d "G:\League of Legends" lol.launcher.exe

Or, if your batch files become more complicated in the future, or your program names have spaces in them, this:

@ECHO OFF

CALL :MainScript
GOTO :EOF

:MainScript
  CALL :RunProgramAsync "C:\Program Files (x86)\LOLReplay\LOLRecorder.exe"
  CALL :RunProgramAsync "G:\League of Legends\lol.launcher.exe"
GOTO :EOF

:RunProgramAsync
  REM ~sI expands the variable to contain short DOS names only
  start %~s1
GOTO :EOF
Burgomaster answered 27/6, 2011 at 1:55 Comment(0)
M
4

start requires parameters for window title. Try: start "Lolrecorder" "C:\Program Files (x86)\LOLReplay\LOLRecorder.exe" start "Lol-Launcher" "G:\League of Legends\lol.launcher.exe"

This will give the cmd-windows started by start the title of "Lolrecorder" and "Lol-Launcher"

Montmartre answered 19/6, 2013 at 4:15 Comment(0)
C
2

Specify a title and the /c switch to tell the STARTed window to go away after its command finishes.

start "recorder" /c "C:\Program Files (x86)\LOLReplay\LOLRecorder.exe"
start "LOL" /c "G:\League of Legends\lol.launcher.exe"

This reference has so far answered almost every question I've ever had about CMD.

Chaparro answered 21/3, 2014 at 14:53 Comment(0)
E
1

call is for batch files only, and it waits for the callee to return. You should use the start command to start programs backgrounded. As an added bonus you can specify a priority for the process. If you need to run something as another user, use runas.

Etam answered 27/6, 2011 at 1:14 Comment(2)
@footy: Do either of the two commands individually (without start) start the respective program correctly, or are you maybe missing some essential command line options? (Oh, no need to say "exit" I think.)Etam
It works individually. There are no cmd line args i have to give to start these programs.Alo
L
0

Someone wandering may be interested in checking correctness of all drives in the same time. Here is a simple .bat file for that:

@echo off
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%a:\ start cmd /c "echo %%a: & chkdsk %%a: & pause"

Script waits for key after checking each drive. Each drive has its own cmd window.

You should avoid checking and fixing (above is only checking) drives, where one drive is a container in another (eg. VeraCrypt container, VHD, VHDX).

Lugar answered 13/9, 2019 at 20:19 Comment(0)
C
0

This works for me, start 2 programs simultaneously with a cmd file without start.

@echo off
"C:\Users\UserA\AppData\Local\Programs\OP.GG\OP.GG.exe" & "C:\Riot Games\Riot Client\RiotClientServices.exe" --launch-product=league_of_legends --launch-patchline=live
exit

The command after "&" will be executed no matter what.

@echo off
programA.exe & programB.exe

The command after "&&" will only be executed if the command before "&&" is executed successfully.

@echo off
programA.exe && programB.exe
Comparison answered 23/4, 2023 at 9:4 Comment(1)
Strange, I had more success using the |, it didn't work for me with the &Evan
E
0

I used the '|', note that only the output of the last executed is shown in the console:

@echo off
Program.exe 50279111 | Program.exe 50279222 | Program.exe 50279333

But in my backend program I can see all three connecting at once.

Evan answered 25/8, 2023 at 14:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.