How to start 2 programs simultaneously in windows command prompt

﹥>﹥吖頭↗ 提交于 2019-11-28 23:24:41

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

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"

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!