After experiencing a lot of down time, We decided to move this site to
CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.
Politely Close all open windows
|
Author |
Message
|
Rischip
-
Total Posts
:
519
- Scores: 2
-
Reward points
:
0
- Joined: 3/26/2007
-
Status: offline
|
Politely Close all open windows
Wednesday, June 13, 2007 9:37 AM
( permalink)
'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
<message edited by Rischip on Thursday, June 14, 2007 7:28 AM>
|
|
|
|
ebgreen
-
Total Posts
:
8088
- Scores: 95
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
RE: Politely Close all open windows
Thursday, June 14, 2007 2:53 AM
( permalink)
Very handy. This chunk: If Not LCase(Right(Wscript.FullName, 11)) = "wscript.exe" Then Set objShell = CreateObject("Wscript.Shell") objShell.Run WScript.ScriptFullName , 0, False WScript.quit End If would re-run the script with whatever the default engine is for that user. In my case, the default engine is CSCript. This means that it would essentially just keep killing itself and starting over. Instead then you should probably have it explicitly run itself with WSCript.exe.
|
|
|
|
Rischip
-
Total Posts
:
519
- Scores: 2
-
Reward points
:
0
- Joined: 3/26/2007
-
Status: offline
|
RE: Politely Close all open windows
Thursday, June 14, 2007 6:52 AM
( permalink)
Yeah my mistake, I posted it before I fixed it. Ok, it's fixed.
<message edited by Rischip on Thursday, June 14, 2007 7:30 AM>
|
|
|
|
Fredledingue
-
Total Posts
:
572
- Scores: 0
-
Reward points
:
0
- Joined: 5/9/2005
- Location: Europe
-
Status: offline
|
RE: Politely Close all open windows
Friday, June 15, 2007 6:10 AM
( permalink)
Works like a charm! And personaly I like the fact that it doesn't requires WMI so that I can run it on my w98++ machine.
|
|
|
|
dm_4ever
-
Total Posts
:
3673
- Scores: 82
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
RE: Politely Close all open windows
Friday, June 15, 2007 12:37 PM
( permalink)
|
|
|
|
robszar
-
Total Posts
:
193
- Scores: 0
-
Reward points
:
0
- Joined: 2/27/2005
- Location:
-
Status: offline
|
RE: Politely Close all open windows
Wednesday, February 11, 2009 9:20 AM
( permalink)
doesn't seem to work with office 2007, bombs here: Set objWord = CreateObject("Word.Application") *UPDATE* It works, my bad
<message edited by robszar on Thursday, February 12, 2009 7:25 AM>
|
|
|
|
cippall
-
Total Posts
:
30
- Scores: 0
-
Reward points
:
0
- Joined: 2/3/2009
-
Status: offline
|
Re:Politely Close all open windows
Sunday, February 14, 2010 2:50 PM
( permalink)
What about when you don't have Microsoft Word installed and you wanna search for a window with a specific title?
|
|
|
|
Online Bookmarks Sharing: