问题
The windows that I am trying to minimise are already running so start /min
is not an option.
回答1:
It can be done with an vbscript
hybrid.
@echo off
set "lookFor=Calculator"
for /f "tokens=2 delims=," %%A in ('tasklist /nh /fo csv /fi "WINDOWTITLE eq %lookfor%"') do set "pid=%%~A"
>"%TEMP%\_edit.vbs" (
echo/Set oShell = CreateObject("WScript.Shell"^)
echo/oShell.AppActivate %pid%
echo/WScript.Sleep 500
echo/oShell.SendKeys "%% (n)" ' minimize (Alt+SpaceBar,n^)
)
start /B cmd /C "CScript //nologo //E:vbs "%TEMP%\_edit.vbs" & rem del /F /Q "%TEMP%\_edit.vbs" 2>NUL"
exit/B
来源:https://stackoverflow.com/questions/39507965/how-would-i-write-a-batch-script-to-either-minimise-all-cmd-windows-or-minimise