Hello,

I need to run a sequence of exes on a remote machine and am using
Win32_Process:Create to launch them. The script must sleep/loop until each
exe finishes before launching the next one.
When the exe is launched, I get the PID for the process; how can I code a
loop to check when the process has ended?

TIA

Re: Wait for process to finish by Joe

Joe
Thu Dec 04 16:53:31 CST 2003

Hi,

"Joe Public" <Joe@home> wrote in message
news:ufcdKqquDHA.3496@TK2MSFTNGP11.phx.gbl...
| Hello,
|
| I need to run a sequence of exes on a remote machine and am using
| Win32_Process:Create to launch them. The script must sleep/loop until each
| exe finishes before launching the next one.
| When the exe is launched, I get the PID for the process; how can I code a
| loop to check when the process has ended?
|
| TIA

The following is air code, but it might be something like:

set oWMI= getObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" _
& sCptrName & "\root\cimv2")

... 'launch and get nPid= pid

do
wscript.sleep 100 'if WSH hosted
qFnd= false
for each oProcess in oWMI.instancesOf( _
"Win32_Process")
qFnd= (oProcess.processId=nPid)
if qFnd then exit for
next
loop while qFnd

Joe Earnest



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 09-23-03



Re: Wait for process to finish by Torgeir

Torgeir
Thu Dec 04 17:27:30 CST 2003

Joe Public wrote:

> I need to run a sequence of exes on a remote machine and am using
> Win32_Process:Create to launch them. The script must sleep/loop until each
> exe finishes before launching the next one.
> When the exe is launched, I get the PID for the process; how can I code a
> loop to check when the process has ended?

Hi

Subject: Monitoring Remote Process for Completion Status
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=LPjLBL31CHA.234%40newsgroup.korea.com



--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter