使用“开始”键 带有传递给启动程序的参数的命令

发布于 2024-07-05 17:26:14 字数 474 浏览 7 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

感情旳空白 2024-07-12 17:26:16

将文件夹中的“Virtual PC.exe”更改为不带空格的名称,例如“VirtualPC.exe”。
当您使用“”编写 start "path" 时,CMD 会启动一个新的 cmd 窗口,并将路径作为标题。
将名称更改为不带空格的名称,将其写在记事本上,然后保存,如Name.cmd或Name.bat:

CD\
CD Program Files
CD Microsoft Virtual PC
start VirtualPC.exe
timeout 2
exit

此命令将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:

CD\
CD Program Files
CD Microsoft Virtual PC
start VirtualPC.exe
timeout 2
exit

This command will redirect the CMD to the folder,start the VirualPC.exe,wait 2 seconds and exit.

百善笑为先 2024-07-12 17:26:16

您可以通过使用 [/D"Path"] 使用引号,使用 /D 指定路径而不是路径+程序。 看起来同一行上的所有代码都恢复正常,这意味着您不需要分隔路径和文件。

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

或者:

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

将使用默认网页启动 IE。

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

从 Bing 开始,但不会重置您的主页。

/D 代表“目录”,使用引号就可以了!

错误示例:

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

给出:

错误“当前目录无效。

/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.

    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

○闲身 2024-07-12 17:26:16

这些答案都不适合我。

相反,我必须使用 Call 命令:

Call "\\Path To Program\Program.exe" <parameters>

我不确定这是否真的等待完成...我正在安装的 C++ Redistributable 运行得足够快,这并不重要

None of these answers worked for me.

Instead, I had to use the Call command:

Call "\\Path To Program\Program.exe" <parameters>

I'm not sure this actually waits for completion... the C++ Redistributable I was installing went fast enough that it didn't matter

冷︶言冷语的世界 2024-07-12 17:26:16

这些空格是 DOS/CMD 问题,因此您应该通过以下方式转到路径:

cd "c:\program files\Microsoft Virtual PC"

然后只需通过以下方式启动 VPC:

start Virtual~1.exe -pc MY-PC -launch

~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:

cd "c:\program files\Microsoft Virtual PC"

and then simply start VPC via:

start Virtual~1.exe -pc MY-PC -launch

~1 means the first exe with "Virtual" at the beginning. So if there is a "Virtual PC.exe" and a "Virtual PC1.exe" the first would be the Virtual~1.exe and the second Virtual~2.exe and so on.

Or use a VNC-Client like VirtualBox.

毁我热情 2024-07-12 17:26:16

如果您想传递参数和 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

韬韬不绝 2024-07-12 17:26:16

“奇特性”中的答案是正确的,直接回答了问题。 正如 TimF 回答的那样,由于第一个参数用引号引起来,因此它被视为窗口标题。

另请注意,虚拟 PC 选项被视为“启动”命令本身的选项,并且对“启动”无​​效。 对于具有“启动”命令的所有 Windows 版本都是如此。

“start”将引用的参数视为标题的问题比发布的问题更烦人。 如果运行此命令:

start "some valid command with spaces"

您将得到一个新的命令提示符窗口,其中包含明显的窗口标题结果。
更烦人的是,这个新窗口没有继承自定义的字体、颜色或窗口大小,它只是 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:

start "some valid command with spaces"

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.

千柳 2024-07-12 17:26:16

如果必须在任何参数处使用双引号,则会收到错误“'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

猫腻 2024-07-12 17:26:16

/b 参数

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

/b parameter

start /b "" "c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc "MY-PC" -launch
昔日梦未散 2024-07-12 17:26:16

你有没有尝试过:

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

have you tried:

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

?

木森分化 2024-07-12 17:26:16

将命令放入批处理文件中,然后使用参数调用它。

另外,你尝试过这个吗? (移动结束引号以封装参数)

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

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"
失退 2024-07-12 17:26:15

您可以在桌面上创建快捷方式,而不是批处理文件。

将目标设置为:

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

一切就绪。 由于您没有启动命令提示符来启动它,因此不会出现 DOS 框。

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.

合约呢 2024-07-12 17:26:14

START 有一个特殊之处,即第一个参数周围有双引号。 如果第一个参数有双引号,它将用作新窗口的可选标题。

我相信你想要的是:

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

换句话说,在程序名称之前给它一个空标题来伪造它。

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:

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

In other words, give it an empty title before the name of the program to fake it out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文