Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View/Close 'Task Manager' applications

Status
Not open for further replies.

hendricksonet

Programmer
May 22, 2005
5
US
Is there any way to view/close applications that are listed in the windows task manager applications tab without having to use the Word.Application object?


The following code works fine, but I need to get this to work even if Word isn't installed on the PC.

********************************************
Brief description: This code looks at the Task Manager App list and closes apps that are not named AppName or Manger
********************************************
Set objWord = CreateObject("Word.Application")
Set colTasks = objWord.Tasks

For Each objTask in colTasks
If objTask.Visible Then
If InStr(CStr(Trim(objTask.Name)),"AppName") OR _
InStR(CStr(Trim(objTask.Name)),"Manager") Then
'do nothing
Else
colTasks(objTask.Name).Close
End If
End If
Next

objWord.Quit
********************************************
 
Here is a code snippet that may help

Code:
' VB Script Document
option explicit
'#### Cleanup any left-over Excel processes ####'
Dim objProcess, colProcess, strComputer, objWMIService
Dim strProcessKill 
strComputer = "."
strProcessKill = "'wzzip.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.Quit 
' End of WMI Example of a Kill Process

hope this helps

Thanks

John Fuhrman
Titan Global Services
 
Yeah, I was trying something similar to that, but it's still using the processes. I need to go based off the window name. Someone else I know is trying to accomplish this via a batch file using tasklist/taskkill. We'll see :) Thanks for the reply though!
 
Shoot, that just seems to just pull in the name of the exe. Thanks though!
 
You might try altering the WMI query to list all the Names and then kill the anything that matches what you need.



Thanks

John Fuhrman
Titan Global Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top