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

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

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

问题描述

我正在使用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)\LOLReplay\LOLRecorder.exe"
call "G:\League of Legends\lol.launcher.exe"
exit

但是除非我关闭LOLRecorder.exe,否则它将不会t启动我的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)\LOLReplay\LOLRecorder.exe"
start "G:\League of Legends\lol.launcher.exe"
exit


推荐答案

问题是引号(不幸的是,由于路径中的空格,引号是必需的)。 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)\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