如何在Windows命令提示符下同时启动2个程序

如何在Windows命令提示符下同时启动2个程序

本文介绍了如何在Windows命令提示符下同时启动2个程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我使用Windows 7 64位



这是我用来启动

的程式码片段

  @echo off 
callC:\Program Files(x86)\LOLReplay\LOLRecorder.exe
callG:\League of Legends \\ \\ lol.launcher.exe
exit

但除非我关闭LOLRecorder.exe启动我的lol.launcher.exe ....基本上我想要两个运行和cmd提示退出后他们开始。这里有什么问题?我检出了另一个stackoverflow回答,但它指的是我使用的相同方法。



编辑:



开始命令它只是启动2个终端窗口,没有开始!

  @echo off 
startC:\Program文件(x86)\LOLReplay\LOLRecorder.exe
startG:\League of Legends \lol.launcher.exe
exit

解决方案

问题是引号(不幸的是,由于路径中的空格,这是需要的)。 start 命令似乎不喜欢它们。



您可以使用短的DOS名称对于所有目录(和删除引号),或通过单独指定目录并引用它( start 命令似乎能够处理)。



尝试以下操作:

  @echo off 
start / dC :\Program Files(x86)\LOLReplayLOLRecorder.exe
start / dG:\League of Legendslol.launcher.exe

或者,如果您的批处理文件在将来变得更复杂,或者您的程序名称中有空格,则:

  @ECHO OFF 

CALL:MainScript
GOTO:EOF

:MainScript
CALL: RunProgramAsyncC:\Program Files(x86)\LOLReplay\LOLRecorder.exe
CALL:RunProgramAsyncG:\League of Legends \lol.launcher.exe
GOTO:EOF

:RunProgramAsync
REM〜sI扩展变量只包含短的DOS名称
start%〜s1
GOTO:EOF


Hi 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 wont 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
解决方案

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

这篇关于如何在Windows命令提示符下同时启动2个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 14:07