WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Window Manipulation

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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
File Created: 2001:06:28:10:59:18
Last Updated: 2001:06:28:10:59:18