How would I write a batch script to either minimise all cmd windows or minimise a window with a given name? [closed]

好久不见. 提交于 2019-12-14 03:26:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!