Quantcast

Maximum PC

It is currently Fri Aug 22, 2014 4:07 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Quick VBS Help
PostPosted: Wed Aug 26, 2009 6:22 pm 
Team Member Top 500
Team Member Top 500
User avatar

Joined: Thu Dec 23, 2004 2:34 pm
Posts: 3974
Location: Building my 4-8-9
I found this code (source)
Code:
' ProcessKillLocal.vbs
' Sample VBScript to kill a program
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.7 - December 2005
' ------------------------ -------------------------------'
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'calc.exe'"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
WSCript.Echo "Just killed process " & strProcessKill _
& " on " & strComputer
WScript.Quit
' End of WMI Example of a Kill Process


I need help adapting it to kill more than one process since I want to run a "battery optimization" script that will kill off the following:
- sidebar.exe
- Moe.exe
- MoeMonitor.exe
- IM-History.exe

These are all processes that drain my battery when I'm in class. The wireless is off, yet the Mesh Operating Environment (Moe and MoeMonitor) continue to drain CPU cycles, as does IM-History. Desktop gadgets are great, except when the entire gadget is obscured by my OneNote and I never see it, so it's just wasting power.

Do I make some kind of list of processes to kill, or can this be done more easily with a batch file? I sorta know how to use TASKKILL.EXE.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Aug 27, 2009 3:36 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
I know this doesn't exactly do it for you... but...

http://www.anappaday.com/downloads/2006 ... kkill.html

I also made this batchfile:

killstuff.bat
Code:
taskkill /IM iPassPeriodicUpdateApp.exe /F
taskkill /IM iPassPeriodicUpdateService.exe /F
taskkill /IM TSVNCache.exe /F
taskkill /IM mqsvc.exe /F
taskkill /IM ctfmon.exe /F
taskkill /IM GoogleUpdate.exe /F
taskkill /IM GoogleUpdate.exe /F
taskkill /IM TscHelp.exe /F
taskkill /IM TSVNCache.exe /F
taskkill /IM sqlwriter.exe /F
taskkill /IM dexplore.exe /F
taskkill /IM AppleMobileDeviceService.exe /F
taskkill /IM ONENOTEEM.EXE /F
taskkill /IM iPodService.exe /F
taskkill /IM iTunesHelper.exe /F


You could also do it with powershell...

the taskkill command I use is pretty basic. /IM for the "image name" and /F to force.


Top
  Profile  
 
 Post subject:
PostPosted: Fri Aug 28, 2009 9:40 pm 
Team Member Top 500
Team Member Top 500
User avatar

Joined: Thu Dec 23, 2004 2:34 pm
Posts: 3974
Location: Building my 4-8-9
CrashTECH wrote:
I also made this batchfile:

killstuff.bat
Code:
taskkill /IM iPassPeriodicUpdateApp.exe /F
taskkill /IM iPassPeriodicUpdateService.exe /F
taskkill /IM TSVNCache.exe /F
taskkill /IM mqsvc.exe /F
taskkill /IM ctfmon.exe /F
taskkill /IM GoogleUpdate.exe /F
taskkill /IM GoogleUpdate.exe /F
taskkill /IM TscHelp.exe /F
taskkill /IM TSVNCache.exe /F
taskkill /IM sqlwriter.exe /F
taskkill /IM dexplore.exe /F
taskkill /IM AppleMobileDeviceService.exe /F
taskkill /IM ONENOTEEM.EXE /F
taskkill /IM iPodService.exe /F
taskkill /IM iTunesHelper.exe /F


You could also do it with powershell...

the taskkill command I use is pretty basic. /IM for the "image name" and /F to force.


I thought a batch file might be better... Just paste that into a text editor, save it as .BAT, go?


Top
  Profile  
 
 Post subject:
PostPosted: Sat Aug 29, 2009 4:03 am 
Team Member [Top 500]*
Team Member [Top 500]*
User avatar

Joined: Thu Jun 24, 2004 2:22 pm
Posts: 8721
Location: Cleveland, Ohio
I like how Crash does it with a .bat file as it is quick, short and a simple approach. This can be done with a VBScript but requires more code to get things done:

Code:
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim xComputer, xProcessKill ,xProcessKill2,xProcessKill3,xProcesskill4
xComputer = "."
xProcessKill = "'Excel.exe'"
xProcessKill2 = "'notepad.exe'"
xProcessKill3 = "'psp.exe'"
xProcessKill4 = "'firefox.exe'"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& xComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill)
For Each objProcess in colProcess
objProcess.Terminate()
Next

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill2)
For Each objProcess in colProcess
objProcess.Terminate()
Next

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill3)
For Each objProcess in colProcess
objProcess.Terminate()
Next

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill4)
For Each objProcess in colProcess
objProcess.Terminate()
Next


The above code in .vbs would kill:

Code:
xProcessKill = "'Excel.exe'"
xProcessKill2 = "'notepad.exe'"
xProcessKill3 = "'psp.exe'"
xProcessKill4 = "'firefox.exe'"


Excel, notepad, paint shop pro and firefox if they are running.

Yes, you would copy and paste Crash's code into notepad and taylor it for your processes to kill and save it as a .bat file (likely to your desktop). That should work just fine.

Ron


Top
  Profile  
 
 Post subject:
PostPosted: Mon Aug 31, 2009 3:46 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Sovereign wrote:
I thought a batch file might be better... Just paste that into a text editor, save it as .BAT, go?
Bingo. I like it because it is simple and gets the job done. The quick kill application I posted works well too. It is nice because you give it a list of things to NOT kill and it kills everything else. Which is sometimes easier.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group