windows 如何在后台从命令行启动 GUI 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6566148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:17:14  来源:igfitidea点击:

How to start a GUI app from the command line in the background?

windowscommand-linebatch-file

提问by Jader Dias

I'm using start cmd.exe /cto start new command line processes in the background. But when I execute GUI apps this way, it creates an unnecessary command line window.

我正在使用start cmd.exe /c在后台启动新的命令行进程。但是当我以这种方式执行 GUI 应用程序时,它会创建一个不必要的命令行窗口。

回答by Joey

If the program you want to start needs to be quoted since it contains spaces or shell metacharacters in its path, then you need to supply an empty quoted argument to start:

如果您要启动的程序需要引用,因为它的路径中包含空格或 shell 元字符,那么您需要提供一个空的引用参数start

start "" "C:\Program Files\SomeProgram\Some program.exe"

That's because startinterprets the first quoted argument as the title for a new console window, running cmd.

这是因为start将第一个引用的参数解释为新控制台窗口的标题,运行cmd.

回答by Kerrek SB

Just say start myprogram.exe. It'll return immediately and it won't start an unnecessary instance of the shell.

就说吧start myprogram.exe。它会立即返回,并且不会启动一个不必要的 shell 实例。