Pat*_*ryk 43 windows windows-7 command-line command-line-arguments
我需要在后台使用start
Windows 7 命令行上的命令启动一个程序(虚拟机)。通常你会这样做:
start /b cmd yourprogram
Run Code Online (Sandbox Code Playgroud)
但是我需要传递一些参数,当我喜欢这个时(没有/b
标志来查看调试信息):
start C:\Users\USER>start "c:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe" -startvm "debian604 64"
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息:
Windows 找不到“-startvm”。确保您输入的名称正确无误,然后重试。
另一方面,当我在当前命令行窗口start
中执行此操作时,虚拟机开始正常运行 - 但在前台。
任何解决方案?
Bob*_*Bob 46
start /b "" "c:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe" -startvm "debian604 64"
Run Code Online (Sandbox Code Playgroud)
如果您使用以下命令阅读参数列表start /?
:
START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
[command/program] [parameters]
"title" Title to display in window title bar.
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.
If it is not an internal cmd command or batch file then
it is a program and will run as either a windowed application
or a console application.
parameters These are the parameters passed to the command/program.
Run Code Online (Sandbox Code Playgroud)
它需要用title
引号 ( "
)括起来。由于您的程序路径包含引号,因此它被解释为标题。添加明确的标题(在本例中为空,""
)有效。
另一种方法是使用/d
开关来指定路径。具体来说:
start /b /d "c:\Program Files\Oracle\VirtualBox\" VBoxHeadless.exe -startvm "debian604 64"
Run Code Online (Sandbox Code Playgroud)
它似乎将/d
switch之后的第一个参数作为路径,即使它被引用,如果下一个参数没有被引用,那么这是有效的。在被识别为命令/程序之后的所有内容都作为参数传递给该命令/程序。请注意,如果命令/程序的名称中有空格,例如VBox Headless.exe
,这将不起作用,因为这需要引号并被识别为标题。
总的来说,第一种(显式标题)方法可能更好。对于微软来说,这是一个糟糕的设计选择,他们真的应该为标题添加一个开关,而不是“第一个参数是否用引号括起来?”。
归档时间: |
|
查看次数: |
332852 次 |
最近记录: |