Link to home
Start Free TrialLog in
Avatar of Husbi
Husbi

asked on

vbscript to call powershell and wait until it complete before loop

I am executing a powershell script from vbscript which passes a paramenter to powershell. The problem is that the loop in vbscript launches multiple pshell windows  . I want the vbscript to wait for powershell script to complete first and then go to the next server in the loop. I dont want to use the wscript.sleep xxx because some of them take more time than others.
Do Until ObjFile.AtEndofStream
strServer = ObjFile.ReadLine
.............
Set objShell = CreateObject("Wscript.Shell")
vPSscript = "powershell.exe -noprofile -command c:\test.ps1 -strHost " & strServer
objShell.Run vPSscript
set objShell  = Nothing
LOOP

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial