如何在 Windows 命令提示符下同时启动 2 个程序 [英] How to start 2 programs simultaneously in windows command prompt
问题描述
我使用的是 Windows 7 64 位
I am using Windows 7 64bit
这是我用来启动的代码片段
Here is the code snippet I am using to start
@echo off
call "C:Program Files (x86)LOLReplayLOLRecorder.exe"
call "G:League of Legendslol.launcher.exe"
exit
但除非我关闭 LOLRecorder.exe,否则它不会启动我的 lol.launcher.exe.... 基本上我希望在它们启动后运行和 cmd 提示符退出.这里有什么问题?我查看了另一个 stackoverflow 答案 这里但它指的是我正在使用的相同方法.
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.
使用 start 命令,它只会启动 2 个终端窗口,但什么也没有启动!
With the start command it just starts 2 terminal windows and nothing starts!
@echo off
start "C:Program Files (x86)LOLReplayLOLRecorder.exe"
start "G:League of Legendslol.launcher.exe"
exit
推荐答案
使用 start 命令,它只会启动 2 个终端窗口,但什么也没有启动!
With the start command it just starts 2 terminal windows and nothing starts!
问题在于引号(不幸的是,由于路径中的空格,引号是必需的).start
命令似乎不喜欢它们.
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.
您可以通过对所有目录使用短 DOS 名称(并删除引号)来解决此问题,或者通过单独指定目录并引用它(start
命令似乎能够处理).
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).
试试这个:
@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)LOLReplayLOLRecorder.exe"
CALL :RunProgramAsync "G:League of Legendslol.launcher.exe"
GOTO :EOF
:RunProgramAsync
REM ~sI expands the variable to contain short DOS names only
start %~s1
GOTO :EOF
这篇关于如何在 Windows 命令提示符下同时启动 2 个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!