How to close all Windows
Keywords: winclose close all windows
Question:
Is there a way to close all the application windows using winbatch, except for one?
Answer:
Try this:
debug(1)
;give the exact title of the application here..
myexacttitle="WinBatch Studio - [C:\WINDOWS\DESKTOP\WinBatch scripts\minimizeall.wbt]"
;gets list of all windows
list=WinItemize()
;gets the number of windows found
count=ItemCount(list,@tab)
for xx=1 to count
;extracts out the first windowname
thiswin=ItemExtract(xx,list,@tab)
;this requires an exact title because we are comparing strings
like=strcmp(myexacttitle,thiswin)
if like==0 then continue;if strings are the same.. continue
;Important to keep the following line because
;it will not shut down any services or hidden processes
if WinState(thiswin)==@HIDDEN then continue
;Important to keep the following line because
;it will not attempt to close windows that don't exist.
if WinState(thiswin)==@FALSE then continue
WinClose(thiswin)
next
Article ID: W13362
Filename: Close all active Windows.txt