How to start 2 programs simultaneously in windows

2019-01-23 04:30发布

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

4条回答
等我变得足够好
2楼-- · 2019-01-23 05:12

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.

查看更多
Deceive 欺骗
3楼-- · 2019-01-23 05:13

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.

查看更多
虎瘦雄心在
4楼-- · 2019-01-23 05:28

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
查看更多
Ridiculous、
5楼-- · 2019-01-23 05:35

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"

查看更多
登录 后发表回答