Help - Search - Members - Calendar
Full Version: Close all windows script
MSFN Forums > Microsoft Software Products - Discussion & Support > Windows 95/98/98SE/ME

   
Google Internet Forums Unattended CD/DVD Guide
Fredledingue
Thanks to a geek named Riship on VBS forum

This script requires MS Word.
I think it can work on every windows.

Copy paste the code below into notepad and save it under Close_all_windows.vbs

CODE
'Author Rischip
'Home page [link=http://www.thegrimlinker.com]www.thegrimlinker.com[/link]
'This script closes all open windows on the workstation
'The script does not forcefully close applications
'therefore you will get a Save dialog on text editor apps and the like
'before they close
'This script requires Microsoft Word to be installed on your computer

On Error Resume Next

'check to ensure running under wscript
'if we are not it would be possible
'for the script to kill itself in the
'command window that cscript would have open
'if we are cool, if not relaunch under wscript

If Not LCase(Right(Wscript.FullName, 11)) = "wscript.exe" Then
  Set objShell = CreateObject("Wscript.Shell")
  objShell.Run "Wscript.exe " & WScript.ScriptFullName , 0, False
  WScript.quit
End If

'create Word object
Set objWord = CreateObject("Word.Application")
'get collection of open windows
Set colTasks = objWord.Tasks
'enumerate open windows
'checking for visibility
'verify task is not program manager
'otherwise you will get the logoff/shutdown/restart window

for each objTask in colTasks
  If objTask.Visible Then
       If Not objTask.Name = "Program Manager" then
          colTasks(objTask.Name).Close
      End If
  End If
  
next

objWord.Quit
whatever420
I use Closing Time...
Works great... smile.gif

"Closing Time is a simple little program you can use to close open windows. It can close hidden windows as well as windows that don't have title bar."

Closing Time v2.10
Rischip
Hey, who are you calling Geek....... LMAO

At least spell my name correctly......
tain
I use this version of close to close windows by title, but it uses wildcards so it can close all windows. It closes them in the "nice" way.

@Rischip: Welcome to MSFN smile.gif
You might be interested in these subforums.
Rischip
Thank You.

This script actually closes windows in a "nice" way as well. If you've made edits to a document for instance. If the program offers the automated notification that the file has changed and to save it. You will get that prompt.

I use this script to close all windows "but", example: you can include the title "Inbox - Microsoft Outlook"
and if you are in Outlook on the Inbox page, it will not be closed. You can add any window title you wish.

Rischip
Fredledingue
If you can manipulate VBScript a little bit, the options are limitless.
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.