windows - cmd 启动命令 ignores/min 开关

标签 windows shell cmd windows-server-2012-r2 minimize

我正在运行 windows 2012,每当我在控制台中输入时:

start /min calc.exe

它会打开应用程序,但不会最小化到任务栏。

在 Windonws 8.1 上它确实最小化了它。

有什么想法吗?

编辑:我想具体说明这个问题,因为它越来越令人困惑。

上面的

calc.exe 只是一个演示/min 开关不起作用的示例。

我的真正目标是通过命令行在 Win 2012 R2 中启动最小化的 pythonchrome

当使用/min 开关时,它们都在 8.1 中最小化启动。

最佳答案

start/min file.exe 使用 CreateProcess启动进程的 API 调用,在 STARTUPINFO 中包含适当的信息lpStartupInfo 参数指向的结构。

在这个结构体中,有一个wShowWindow成员来表示如何显示启动进程的窗口。它的文档说明

wShowWindow

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.

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 命令中执行任何操作来确保新窗口最小化。

注意:start 命令在可执行文件的情况下使用CreateProcess,但不同的参数(文档、URL、... ) 导致使用不同的 API(例如 ShellExecuteShellExecuteEx),但在遵循不同的路径后您会遇到相同的问题。

注意 2:如前所述,在某些情况下(我的情况是 Windows 10,calc.exe)您启动了一个进程,它又启动了另一个进程。您无法控制第二个启动的进程。

关于windows - cmd 启动命令 ignores/min 开关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43160012/

相关文章:

Python unicode popen 或 Popen 错误读取 unicode

windows - 有没有办法在当前文件夹中打开命令提示符?

windows - 退出前是否需要 endlocal ?

windows - 为什么它不告诉我我的选择?

java - FTP Get 适用于 Windows,但不适用于 Linux

c++ - 如何在 Windows 7 上构建和安装 GCC,ver。 4.8.1

c++ - Mingw-x64 中的类型错误

linux - 脚本持续运行数小时

windows - Docker 端口绑定(bind)失败。为什么是 "permission denied"?

php - 从 php 运行 shell 命令,