Solved

VBScript logic to wait for a child process to end

Posted on 2010-11-09
3
2,888 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

943 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

6 Experts available now in Live!

Get 1:1 Help Now