Smoreno wrote:
Quote:
> Other than calling WMI, is there another way to kill the process via script
> that doesn't take a long time?
>
hi Smoreno,
In addition to wmi and the previously mentioned TaskKill,
I suggest taking a look at sysInternals "Process Explorer":
http://technet.microsoft.com/en-us/s.../bb896653.aspx
The sysInternals group was previously run by Mark Russinovich,
but has since been taken over by microsoft (as you can see by
the url). The Process Explorer utility will tell you everything
you ever wanted to know about your running processes, and more
to the point will allow you to kill a process (either from the
main menu, or a context menu). However, I can't say whether
it will be any faster than wmi, except that M.R. is one clever
guy and if there is a faster way -- he knows it.
The Process Explorer utility is not scriptable, other than via
appactivate and sendkeys. However I would strongly advise against
sending keys (ever!), and just using the gui provided.
If you happen to be courageous enough, or foolhardy enough to
call api's from script, then that is probably the "fastest way"
to kill a process. There are plenty of code samples available
to show how to do it. In short, you "walk-the-process-list"
(there are different ways to do this, depending on the system
you are using). You walk-the-process-list to get the process ID
of the process you are looking to terminate. Then to terminate
the process you use OpenProcess to open the process for termination,
then you use TerminateProcess api. WMI is nothing more than a
scriptable interface to this sort of code. Any delays you are
seeing may be due to the fact that it is not so simple to terminate
a process. There is a lot of "checking" to do (looking for child
threads, child processes, de-allocating system resources, freeing
dll's, etc). There is a "laundry list" to things that must be done
to properly terminate a process, and that may be taking time.
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)