Solved

VBScript logic to wait for a child process to end

Posted on 2010-11-09
3
2,852 Views
Last Modified: 2012-08-14
Hi,
I'm writing a VBScript wrapper to manage an application install. I've used
     wshShell.run setup.exe,0,True
to launch the executable.  The problem is that setup.exe spawns _setup.exe, then setup.exe terminates.  Is there a method to wait until all spawned processes terminate?
Thanks.
0
Comment
Question by:netrxinc
3 Comments
 
LVL 16

Accepted Solution

by:
jmatix earned 500 total points
ID: 34096943
One option is to do a winmgmts query on process with name '_setup.exe' and wait until the process count is zero.


wshShell.run setup.exe,0,True



set svc=getobject("winmgmts:root\cimv2")

sQuery="select * from win32_process where name='_setup.exe'"



Do

set cproc=svc.execquery(sQuery)

If cproc.count = 0 Then

	Exit Do

End If

WScript.Sleep 1000

Loop

Open in new window

0
 
LVL 12

Expert Comment

by:Daz_1234
ID: 34100643
Hi netrxinc,

While the 2nd process _setup.exe is still running, open a command prompt and run:

wmic process get commandline | find /i "_setup.exe"

This will list the processes called _setup.exe but will show the complete command line used to call it.

Then once you have the command line, try calling that (the _setup.exe) from your vbscript instead of the main Setup.exe.

(by the way this isn't anything to with SAP is it?)

Good luck,
Daz.
0
 

Author Closing Comment

by:netrxinc
ID: 34111881
Thanks.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now