【发布时间】:2022-01-09 17:54:26
【问题描述】:
给定一个单实例桌面应用程序 ccTest.exe,如果它已经在最小化状态下运行,我如何使用 PowerShell(v6 或 7)在正常状态下运行该应用程序。
我需要访问主窗口中的控件,因此它必须处于正常状态。 Get-Process 用于检查应用程序是否正在运行。如果没有,则使用 Start-Process 和 -WindowStyle Normal 参数启动它。但是如果单实例应用程序已经在运行 Minimized,则 Start-Process 不起作用。
由于时间限制,如果最小化,我宁愿不关闭 ccTest.exe,然后使用 Start-Process 启动。这是测试代码。
if (Get-Process | Select MainWindowTitle, ProcessName, Id | where {$_.MainWindowTitle -like "ccTest*"})
{
if Minimized make it Normal
execute needed function
}
else
{
start-process "C:\Program Files (x86)\Test\ccTest.exe" -WindowStyle Normal
execute needed function
}
那么如何将 State/Style 从 Minimized 更改为 Normal 以运行所需的功能?
【问题讨论】:
标签: windows powershell start-process