windows-7command-linecmdcommand-promptwindows-console

How to start 2 programs simultaneously in windows command prompt


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

Solution

  • 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