I need to start a program (virtual machine) in the background with a start
command on Windows' 7 command line. Normally you would do this like that:
start /b cmd yourprogram
But I need to pass some arguments and when I so it like this (without /b
flag to see the debug information):
start C:\Users\USER>start "c:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe" -startvm "debian604 64"
I get this error message:
Windows cannot find '-startvm'. Make sure you typed the name
correctly, and then try again.
On the other hand when I do it in the current command line window without the start
in the beginning the virtual machine runs normally – but in the foreground.
Any solutions?
Best Answer
If you read the parameter list with
start /?
:It expects a
title
enclosed in quotes ("
). Since your program path included quotes, it got interpreted as the title. Adding an explicit title (in this case, empty,""
) works.An alternative method is using the
/d
switch to specify the path. Specifically:It appears to take the first argument after the
/d
switch as the path, even if it is quoted, and if the next argument is not quoted then this works. Everything after what is recognised as the command/program is passed as a parameter to that command/program. Note this will not work if the command/program has spaces in the name, e.g.VBox Headless.exe
, since that would require quotes and be recognised as a title.Overall, the first (explicit title) method is probably better. It was a bad design choice on the part of Microsoft, they really should have added a switch for title rather than "is the first argument enclosed in quotes?".