Retrieving Task Manager's processes

R

Ron

How does one traverse the Task Manager's process list to obtain the Image
Name and ID so that selected one's can be killed?

I tried using the Tasks collection in Word Applications but it does not give
one the Image Names as seen in the Task Manager. I have some WinWord.exe
processes to kill that do not have a filename associated with them.
 
A

Amedee Van Gasse

Ron schreef in said:
How does one traverse the Task Manager's process list to obtain the
Image Name and ID so that selected one's can be killed?

I tried using the Tasks collection in Word Applications but it does
not give one the Image Names as seen in the Task Manager. I have some
WinWord.exe processes to kill that do not have a filename associated
with them.

In Windows XP there is a command called "taskkill".
Execute it from the command prompt with -help for more info.


Alternatively (and for all Windowses starting from NT, through 2K, XP,
2003 and possible all those that will follow, but NOT for the old
windozes like 95/98/Me) you could use the WindowsScriptingObject or some
other external object references.
This is a "smart" but possible "difficult" approach.
In the Microsoft Script Center I found this example code:

----- CUT HERE -----
Description
Terminates any running instances of Notepad.exe.

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Notepad.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next


For online peer support, join the
microsoft.public.windows.server.scripting community on the
msnews.microsoft.com news server. To provide feedback or report bugs in
sample scripts or the Scripting Guide, please contact Microsoft TechNet.
----- CUT HERE -----

This code is written in VBScript so it should be portable to Excel VBA,
assuming also you have the right permissions to terminate processes on
your computer.

Please note that I have very limited "live" experience with Windows
Scripting so I really don't know if it will work in VBA and I can't help
you if it doesn't.


--
Amedee Van Gasse

To top-post is human, to bottom-post and snip is sublime.

Dit bericht is geplaatst in een nieuwsgroep. Post je evt antwoord of
vervolgvraag graag in dezelfde thread in de nieuwsgroep a.u.b.
 
A

Amedee Van Gasse

Amedee Van Gasse schreef in <194.109.133.29>:
This code is written in VBScript so it should be portable to Excel VBA,
assuming also you have the right permissions to terminate processes on
your computer.

Uhhh... Excel VBA or just Office VBA, that's the same.
I only use Excel to write VBA, I have no experience whatsoever using VBA in
Word.

--
Amedee Van Gasse

To top-post is human, to bottom-post and snip is sublime.

Dit bericht is geplaatst in een nieuwsgroep. Post je evt antwoord of
vervolgvraag graag in dezelfde thread in de nieuwsgroep a.u.b.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top