Using the “start” command with parameters passed t

2019-01-01 10:08发布

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?

11条回答
步步皆殇っ
2楼-- · 2019-01-01 10:43

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.

    start  /D "C:\Program Files\Internet Explorer\" IEXPLORE.EXE

or:

    start  /D "TITLE" "C:\Program Files\Internet Explorer\" IEXPLORE.EXE

will start IE with default web page.

    start  /D "TITLE" "C:\Program Files\Internet Explorer\" IEXPLORE.EXE www.bing.com

starts with Bing, but does not reset your home page.

/D stands for "directory" and using quotes is OK!

WRONG EXAMPLE:

    start  /D "TITLE" "C:\Program Files\Internet Explorer\IEXPLORE.EXE"

gives:

ERROR "The current directory is invalid."

/D must only be followed by a directory path. Then space and the batchfile or program you wish to start/run

Tested and works under XP but windows Vista/7/8 may need some adjustments to UAC.

-Mrbios

查看更多
还给你的自由
3楼-- · 2019-01-01 10:46

have you tried:

start "c:\program files\Microsoft Virtual PC\Virtual PC.exe" "-pc MY-PC -launch"

?

查看更多
长期被迫恋爱
4楼-- · 2019-01-01 10:47

Instead of a batch file, you can create a shortcut on the desktop.

Set the target to:

"c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc "MY-PC" -launch

and you're all set. Since you're not starting up a command prompt to launch it, there will be no DOS Box.

查看更多
倾城一夜雪
5楼-- · 2019-01-01 10:54

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)

start "c:\program files\Microsoft Virtual PC\Virtual PC.exe -pc MY-PC -launch"
查看更多
刘海飞了
6楼-- · 2019-01-01 10:59

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

查看更多
泪湿衣
7楼-- · 2019-01-01 11:00

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

查看更多
登录 后发表回答