finding process and waiting for it to end
- From: "stgagnon" <stgagnon@xxxxxxxxxxxxx>
- Date: 7 Sep 2005 14:21:43 -0700
Hi:
I am working on a jscript that launches a process (proc1).
Proc1 launches a secondary process (proc2) and then exits.
I want my script to launch proc1 and then find the process associated
with proc2. So far I am doing this.
Now I want my script to watch the status of proc2 and when proc2
terminates, take some additional action.
I'm having trouble with the latter.
After launching proc1, the script sleeps for a bit and then searches
for proc2:
var e=new Enumerator
(GetObject("winmgmts:").InstancesOf("Win32_process"));
for (;!e.atEnd();e.moveNext())
{
var p = e.item ();
if (p.Name == "proc2.exe")
{
WScript.Echo (p.Name, p.Handle, p.Status );
// take additional action here...
}
}
I have a couple of questions.
First of all, am I going about this the right way? Can I monitor the
p.Status property and wait until the process goes away?
Second, the docs tell me that Win32_process.Status is a string with
values "OK", "Error", etc.. but when I display the value of status in
this code snippet, it always comes out as "null" .. How come?
Thanks for your help
S.
.
- Follow-Ups:
- Re: finding process and waiting for it to end
- From: Serge Baltic
- Re: finding process and waiting for it to end
- Prev by Date: Get Focus
- Next by Date: Re: Resizable not working in Window.open
- Previous by thread: Get Focus
- Next by thread: Re: finding process and waiting for it to end
- Index(es):
Relevant Pages
|