How can I kill a stuck cmd.exe remotely?

C

cschang

On my NT 4 server with sp6, I set up a scheduled task to run a cmd job
regularly, which includes a bunch of commands and exe files. Sometimes,
the cmd would stuck for some reasons I did not know. The only solution
I did was to using the task manager to kill that cmd process locally.
I want to know how I can set a process (using the WSHost script) to
kill that cmd remotely from my Windows 2000 station. I have that
killProc.vbs locally. How can I set up so that the script file will
connect to that NT 4 server and kill the stuck cmd. Does the NT 4
server need to install something in order to run the WMI thing? Or the
WMI process is not available on NT platform? Thanks.

C Chang
 
S

Scott McNairy \(MVP\)

You would want to use the Win32_process.Terminate method, the class resides
in the root\cimv2 namespace.

sample script code...

set svc = getObject("winmgmts:root\cimv2")
set objEnum = svc.ExecQuery("Select * from win32_process where caption =
'calc.exe'")
for each obj in objEnum
obj.Terminate(1)
next

WMI is available for NT4 but has to be installed separately, I believe that
it is a part of the NT4 SP4 installation media. If not, you can download it
from this location.

http://www.microsoft.com/downloads/...46-e213-4cbf-9c5b-fbf236e0e875&displaylang=en
 

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