使用“开始”键 带有传递给启动程序的参数的命令
我在 Virtual PC 2007 中有一个虚拟机。
要从桌面启动它,我在批处理文件中包含以下命令:
"c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc "MY-PC" -launch
但这会在主机上留下 dos 提示符,直到虚拟机关闭,然后我退出虚拟 PC 控制台。 这很烦人。
因此,我将命令更改为使用 START 命令:
start "c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc MY-PC -launch
但它会因传递到 Virtual PC 的参数而阻塞。
START /?
表示参数确实位于该位置。 有人使用 START 来启动带有多个命令行参数的程序吗?
I have a Virtual Machine in Virtual PC 2007.
To start it from the desktop, I have the following command in a batch file:
"c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc "MY-PC" -launch
But that leaves a dos prompt on the host machine until the virtual machine shuts down, and I exit out of the Virtual PC console. That's annoying.
So I changed my command to use the START command, instead:
start "c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc MY-PC -launch
But it chokes on the parameters passed into Virtual PC.
START /?
indicates that parameters do indeed go in that location. Has anyone used START to launch a program with multiple command-line arguments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
将文件夹中的“Virtual PC.exe”更改为不带空格的名称,例如“VirtualPC.exe”。
当您使用“”编写
start "path"
时,CMD 会启动一个新的 cmd 窗口,并将路径作为标题。将名称更改为不带空格的名称,将其写在记事本上,然后保存,如Name.cmd或Name.bat:
此命令将CMD重定向到该文件夹,启动VirualPC.exe,等待2秒并退出。
Change The "Virtual PC.exe" to a name without space like "VirtualPC.exe" in the folder.
When you write
start "path"
with "" the CMD starts a new cmd window with the path as the title.Change the name to a name without space,write this on Notepad and after this save like Name.cmd or Name.bat:
This command will redirect the CMD to the folder,start the VirualPC.exe,wait 2 seconds and exit.
您可以通过使用 [
/D"Path"
] 使用引号,使用/D
仅指定路径而不是路径+程序。 看起来同一行上的所有代码都恢复正常,这意味着您不需要分隔路径和文件。或者:
将使用默认网页启动 IE。
从 Bing 开始,但不会重置您的主页。
/D
代表“目录”,使用引号就可以了!错误示例:
给出:
/D
后面只能跟一个目录路径。 然后是空格和您希望启动/运行的批处理文件或程序经过测试并在 XP 下工作,但 Windows Vista/7/8 可能需要对 UAC 进行一些调整。
-Mrbios
You can use quotes by using the [
/D"Path"
] use/D
only for specifying the path and not the path+program. It appears that all code on the same line that follows goes back to normal meaning you don't need to separate path and file.or:
will start IE with default web page.
starts with Bing, but does not reset your home page.
/D
stands for "directory" and using quotes is OK!WRONG EXAMPLE:
gives:
/D
must only be followed by a directory path. Then space and the batchfile or program you wish to start/runTested and works under XP but windows Vista/7/8 may need some adjustments to UAC.
-Mrbios
这些答案都不适合我。
相反,我必须使用 Call 命令:
我不确定这是否真的等待完成...我正在安装的 C++ Redistributable 运行得足够快,这并不重要
None of these answers worked for me.
Instead, I had to use the Call command:
I'm not sure this actually waits for completion... the C++ Redistributable I was installing went fast enough that it didn't matter
这些空格是 DOS/CMD 问题,因此您应该通过以下方式转到路径:
然后只需通过以下方式启动 VPC:
~1
表示第一个带有“Virtual”的
开头。 因此,如果存在exe
“Virtual PC.exe”
和“Virtual PC1.exe”
,第一个将是Virtual~1.exe
和第二个Virtual~2.exe
等等。或者使用 VirtualBox 等 VNC 客户端。
The spaces are DOSs/CMDs Problems so you should go to the Path via:
and then simply start VPC via:
~1
means the firstexe
with"Virtual"
at the beginning. So if there is a"Virtual PC.exe"
and a"Virtual PC1.exe"
the first would be theVirtual~1.exe
and the secondVirtual~2.exe
and so on.Or use a VNC-Client like VirtualBox.
如果您想传递参数和 c: 驱动器测试文件夹中的 .exe 文件
start "parameter" "C:\test\test1.exe" -pc My Name-PC -launch
如果您愿意'不想在 c: 驱动器的测试文件夹中传递参数和 .exe 文件
start "" "C:\test\test1.exe" -pc My Name-PC -launch
如果您不想在 H: (Any Other)drive 的测试文件夹中传递参数和您的 .exe 文件
start "" "H:\test\test1.exe" -pc My Name-PC -launch
If you want passing parameter and your .exe file in test folder of c: drive
start "parameter" "C:\test\test1.exe" -pc My Name-PC -launch
If you won't want passing parameter and your .exe file in test folder of c: drive
start "" "C:\test\test1.exe" -pc My Name-PC -launch
If you won't want passing parameter and your .exe file in test folder of H: (Any Other)drive
start "" "H:\test\test1.exe" -pc My Name-PC -launch
“奇特性”中的答案是正确的,直接回答了问题。 正如 TimF 回答的那样,由于第一个参数用引号引起来,因此它被视为窗口标题。
另请注意,虚拟 PC 选项被视为“启动”命令本身的选项,并且对“启动”无效。 对于具有“启动”命令的所有 Windows 版本都是如此。
“start”将引用的参数视为标题的问题比发布的问题更烦人。 如果运行此命令:
您将得到一个新的命令提示符窗口,其中包含明显的窗口标题结果。
更烦人的是,这个新窗口没有继承自定义的字体、颜色或窗口大小,它只是 cmd.exe 的默认值。
The answer in "peculiarity" is correct and directly answers the question. As TimF answered, since the first parameter is in quotes, it is treated as a window title.
Also note that the Virtual PC options are being treated as options to the 'start' command itself, and are not valid for 'start'. This is true for all versions of Windows that have the 'start' command.
This problem with 'start' treating the quoted parameter as a title is even more annoying that just the posted problem. If you run this:
You get a new command prompt window, with the obvious result for a window title.
Even more annoying, this new window doesn't inherit customized font, colors or window size, it's just the default for cmd.exe.
如果必须在任何参数处使用双引号,则会收到错误“'c:\somepath' 无法识别为内部或外部命令、可操作程序或批处理文件”。
使用双引号时我建议以下解决方案:
https://stackoverflow.com/a/43467194/3835640
If you must use double quotation mark at any parameter, you can get error "'c:\somepath' is not recognized a an internal or external command, operable program or batch file".
I suggest below solution when using double qoutation mark:
https://stackoverflow.com/a/43467194/3835640
/b
参数/b
parameter你有没有尝试过:
?
have you tried:
?
将命令放入批处理文件中,然后使用参数调用它。
另外,你尝试过这个吗? (移动结束引号以封装参数)
Put the command inside a batch file, and call that with the parameters.
Also, did you try this yet? (Move end quote to encapsulate parameters)
您可以在桌面上创建快捷方式,而不是批处理文件。
将目标设置为:
一切就绪。 由于您没有启动命令提示符来启动它,因此不会出现 DOS 框。
Instead of a batch file, you can create a shortcut on the desktop.
Set the target to:
and you're all set. Since you're not starting up a command prompt to launch it, there will be no DOS Box.
START 有一个特殊之处,即第一个参数周围有双引号。 如果第一个参数有双引号,它将用作新窗口的可选标题。
我相信你想要的是:
换句话说,在程序名称之前给它一个空标题来伪造它。
START has a peculiarity involving double quotes around the first parameter. If the first parameter has double quotes it uses that as the optional TITLE for the new window.
I believe what you want is:
In other words, give it an empty title before the name of the program to fake it out.