Kill Open Applications Script

I tend to put my laptop to “sleep” at the end of the office day but often fire it back up at home. One bad habit of mine is having too many apps running at the same time (thanks to UltraMon the problem is now worse).  Putting a PC into “sleep” tries to commit things to RAM and if it runs out (it does) then to hard disk.  “Awakening” causes it to push things off of the hard disk and back into memory.  This takes a long time.  My solution was a simple VBS script to transverse and kill the most common applications right before “sleep”.  I’ve tied this to a slickrun command “kill” to make it easier to run.  Script below, enjoy!

 

strComputer = "."

dim oKillThese
oKillThese = Array("firefox.exe", "iexplorer.exe", "safari.exe", "TweetDeck.exe", "OUTLOOK.EXE", "chrome.exe", "notepad++.exe", "iTunes.exe", "javaw.exe", "cmd.exe", "Moe.exe", "Surround SCM Client.exe", "devenv.exe", "SqlWb.exe", "Navicat.exe")

For Each x in oKillThese

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Process WHERE Name = ‘" & x & "’")
For Each objProcess in colProcessList
    objProcess.Terminate()
Next

Next

Written by Tim on October 7th, 2008 with 2 comments.
Read more articles on windows.



Related articles

2 comments

Read the comments left by other users below, or:

Get your own gravatar by visiting gravatar.com Jonathan
#1. October 7th, 2008, at 10:24 PM.

As if one browser isn’t enough…you expect to [possibly] have four open. Multitasking?

Get your own gravatar by visiting gravatar.com Tim
#2. October 7th, 2008, at 11:15 PM.

I am an internet engineer after all

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .