Windows 如何使用batch/powershell最小化除当前窗口外的所有窗口

Windows 如何使用batch/powershell最小化除当前窗口外的所有窗口,windows,powershell,batch-file,Windows,Powershell,Batch File,我想最小化除当前窗口外的所有窗口 对,对, 有一个答案,但它只适用于nircmd。但是,我希望它在没有nircmd.exe的设备上工作 我该怎么做 虽然允许使用powershell,但小批量脚本也不错 我使用了这个函数,最小化了除了运行脚本的进程之外的所有内容: $self = [System.Diagnostics.Process]::GetCurrentProcess() Get-Process | ? { $_.Id -ne $self.Id } | % { Set-WindowSt

我想最小化除当前窗口外的所有窗口

对,对, 有一个答案,但它只适用于nircmd。但是,我希望它在没有nircmd.exe的设备上工作

我该怎么做

虽然允许使用powershell,但小批量脚本也不错

我使用了这个函数,最小化了除了运行脚本的进程之外的所有内容:

$self = [System.Diagnostics.Process]::GetCurrentProcess()
Get-Process | ? { $_.Id -ne $self.Id } | % {
   Set-WindowStyle -Style MINIMIZE -MainWindowHandle $_.MainWindowHandle
}

我会考虑使用ToggleDesktop API,然后“恢复”我自己的窗口。但是,powershell脚本能否控制自己的窗口来执行恢复?