Cmd start命令忽略/min开关 [英] Cmd start command ignores /min switch
问题描述
我正在运行Windows 2012,并且每当我在控制台中键入以下内容时:
I'm running windows 2012 and whenever I type this in console:
start /min calc.exe
它会打开应用程序,但不会最小化到任务栏.
It opens the application but, it's not minimized to taskbar.
在Windonws 8.1上,实际上确实将其最小化.
On Windonws 8.1 it actually does minimize it.
有什么想法吗?
编辑:由于该问题越来越令人困惑,我想具体说明一下.
I want to be specific about this question as it is getting confused.
calc.exe 只是一个示例,用于演示/min开关不起作用.
calc.exe above was just an example to demonstrate that /min switch is not working.
我的真正目标是通过命令行在Win 2012 R2中启动最小化的 python 和 chrome .
My real goal is to launch python and chrome minimized in Win 2012 R2 via command line.
当使用/min开关时,它们两者的启动都在8.1中最小化.
Both of them do launch minimized in 8.1 when using the /min switch.
推荐答案
start /min file.exe
使用 STARTUPINFO
结构,该结构由lpStartupInfo
参数指向.
在此结构内,有一个wShowWindow
成员指示如何显示已启动进程的窗口.其文档说明
Inside this structure, there is a wShowWindow
member to indicate how to show the window of the started process. Its documentation states
wShowWindow
如果 dwFlags 指定STARTF_USESHOWWINDOW,则该成员可以是以下任何一个 可以在 nCmdShow 参数中为 ShowWindow函数,SW_SHOWDEFAULT除外.否则,此成员 被忽略.
If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of the values that can be specified in the nCmdShow parameter for the ShowWindow function, except for SW_SHOWDEFAULT. Otherwise, this member is ignored.
对于GUI进程,是首次调用ShowWindow,即它的 nCmdShow 参数被忽略 wShowWindow 指定默认值.在 随后调用ShowWindow,如果 wShowWindow成员 ShowWindow的 nCmdShow 参数设置为SW_SHOWDEFAULT.
For GUI processes, the first time ShowWindow is called, its nCmdShow parameter is ignored wShowWindow specifies the default value. In subsequent calls to ShowWindow, the wShowWindow member is used if the nCmdShow parameter of ShowWindow is set to SW_SHOWDEFAULT.
也就是说,您依赖,取决于启动的进程如何处理其窗口管理.您无法在start
命令中执行任何操作来确保新窗口最小化.
That is, you depend on how the started process handles its window management. There is nothing you could do in the start
command to ensure the new window will be minimized.
注释:对于可执行文件,start
命令使用CreateProcess
,但是不同的参数(文档,URL等)导致使用不同的API(例如ShellExecute
或ShellExecuteEx
),但是在使用不同的路径后,您会遇到相同的问题.
note: start
command uses CreateProcess
in the case of executable files, but different arguments (a document, a URL, ...) lead to different APIs used (Ex. ShellExecute
or ShellExecuteEx
), but you end in the same problem after following a different path.
注释2 :正如已经提到的,在某些情况下(例如Windows 10,calc.exe
),您启动了一个进程,然后又启动了一个进程.您无法控制第二个启动过程.
note 2: As already commented, in some cases (my case, windows 10, calc.exe
) you start a process and it starts another one. You have not control on the second started process.
这篇关于Cmd start命令忽略/min开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!