Re: Terminating a process
From: Dennis Hancy (dennishancy_at_eaton.com)
Date: 07/06/04
- Next message: Polaris: "ActiveX control not downloading is put in sub-directory..."
- Previous message: aptrsn: "Copy *.xml comes back with error"
- In reply to: Tom Lavedas: "RE: Terminating a process"
- Next in thread: Tom Lavedas: "Re: Terminating a process"
- Reply: Tom Lavedas: "Re: Terminating a process"
- Messages sorted by: [ date ] [ thread ]
Date: 6 Jul 2004 11:40:17 -0700
Tom,
I tried this code as is (except I changed RunThis.exe to my own exe
file). However, the exe file still shows up in the task manager.
I am not sure I know what WMI is. Do I need to do something special
to make it run? Or will it run as listed? I included some debug
msgbox statements in my code, so I know that it found my exe file.
Just not sure why it still shows up in the task manager.
Thanks.
Dennis
"Tom Lavedas" <tlavedas@hotmail.remove.com> wrote in message news:<C44AC7EA-2DBC-44D3-9716-29D4DAF2FB55@microsoft.com>...
> Setting that object to Nothing has no effect because the wshShell is no longer attached to the RunThis.exe thread. The third argument on the Run line made sure that this was the case.
>
> You need to use WMI to either create the thread in the first place or to search for the thread's PID to permit termination under your script's control.
>
> For example, from the Script Center's sample library ...
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set colProcessList = objWMIService.ExecQuery _
> ("Select * from Win32_Process Where Name = 'RunThis.exe'")
> For Each objProcess in colProcessList
> objProcess.Terminate()
> Next
>
> There is also a process creation class (Win32_ProcessStartup) that returns the PID directly at the time the thread is created, but it's way complicated to use (I think ;-)
>
> Tom Lavedas
> ===========
>
> Microsoft® Windows®2000 Scripting Guide (URL all one line)
> http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp
>
> TechNet Script Center Sample Scripts (URL all one line)
> http://www.microsoft.com/downloads/release.asp?ReleaseID=38942
>
> "Dennis Hancy" wrote:
>
> > I have code in a .wsf file:
> >
> > Set wshShell = WScript.CreateObject("WScript.Shell")
> > wshShell.Run RunThis.exe, 0, false
> >
> > It does some other processing, and before the program ends, it runs
> > this command:
> >
> > Set wshShell = nothing
> >
> >
> >
> > However, when the script ends, RunThis.exe still shows up as an active
> > process in my Task Manager.
> >
> > Any idea why this process isn't being killed as a result of the last
> > command?
> >
> >
> > Dennis Hancy
> > Eaton Corporation
> > Cleveland, OH
- Next message: Polaris: "ActiveX control not downloading is put in sub-directory..."
- Previous message: aptrsn: "Copy *.xml comes back with error"
- In reply to: Tom Lavedas: "RE: Terminating a process"
- Next in thread: Tom Lavedas: "Re: Terminating a process"
- Reply: Tom Lavedas: "Re: Terminating a process"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|