运行 Windows 批处理脚本以启动多个文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/287849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running a Windows Batch Script to Startup Multiple Files
提问by Trevor Abell
I'm trying to replace the programs that run from my startup directory with a batch script. The batch script will simply warn me that the programs are going to run and I can either continue running the script or stop it.
我正在尝试用批处理脚本替换从我的启动目录运行的程序。批处理脚本只会警告我程序将要运行,我可以继续运行脚本或停止它。
Here's the script as I have written so far:
这是我迄今为止编写的脚本:
@echo off
echo You are about to run startup programs!
pause
::load outlook
cmd /k "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE" /recycle
::load Visual Studio 2008
call "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
Both of these commands will load the first program and wait until I close it to load the second. I want the script to load the processes simultaneously. How do I accomplish this?
这两个命令都将加载第一个程序并等到我关闭它以加载第二个。我希望脚本同时加载进程。我该如何实现?
Edit: When I use the start command it opens up a new shell with the string that I typed in as the title. The edited script looks like this:
编辑:当我使用 start 命令时,它会打开一个新的 shell,其中包含我输入的字符串作为标题。编辑后的脚本如下所示:
start "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE"
::load Visual Studio 2008
start "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
回答by R?mulo Ceccon
This works:
这有效:
@echo off echo You are about to run startup programs! pause ::load outlook start /b "" "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE" /recycle ::load Visual Studio 2008 start /b "" "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
回答by aphoria
Use START like this:
像这样使用 START:
START "" "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE"
When your path is enclosed in quotes, START interprets it as the title for the window. Adding the "" makes it see your path as the program to run.
当您的路径用引号引起来时,START 会将其解释为窗口的标题。添加“”使其将您的路径视为要运行的程序。
回答by Carl Seleborg
There is the start
command that will behave much like if you clicked the files in Explorer.
start
如果您在资源管理器中单击文件,则该命令的行为将非常相似。