finding process and waiting for it to end



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.

.



Relevant Pages

  • Re: Accessing variable defined in one proc, in another proc
    ... One way is to return that variable form that proc to the main script ... proc proc1 { ... proc proc2 { ...
    (comp.lang.tcl)
  • waiting for input of widget and return input value
    ... run proc1, then proc1 will invoke proc2 and popup some checkbutton for ... to invoke proc3, proc3 will check which button was checked and return a ... checked variable list, then proc2 return the list to proc1, and proc1 ... proc proc1 { ...
    (comp.lang.tcl)
  • Re: Is this a legitimate use of "reutrn -level"?
    ... puts "This is proc0" ... proc proc1 { ... proc proc2 { ...
    (comp.lang.tcl)
  • Re: About Lists of Pointers
    ... > In Proc1, the address of a local variable is pushed. ... is NOT the same as Addr, although both return pointers. ... When Proc2 gets called ...
    (borland.public.delphi.language.objectpascal)
  • Re: About Lists of Pointers
    ... "Steve B" wrote ... > In Proc1, the address of a local variable is pushed. ... > So why is the address still valid in Proc2? ... "by chance". ...
    (borland.public.delphi.language.objectpascal)