Sometime it is required to wait for some process exeution to go for next execution step in VBScript, In such scenario following piece of code can be useful.
Dim colProcesses, objWmi
Set objWmi=GetObject ("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objShell = CreateObject("WScript.Shell")
objShell.Run "ping 1.1.1.1 -n 1 -w 30000",0,True
Set colProcesses=objWmi.ExecQuery ("Select * From Win32_Process Where Name='Setup.exe'")
Do While colProcesses.Count<>0
Set colProcesses=objWmi.ExecQuery ("Select * From Win32_Process Where Name='Setup.exe'")
objShell.Run "ping 1.1.1.1 -n 1 -w 30000",0,True
Loop
Ping can be replace with Wait also
Ex : objShell.Run "ping 1.1.1.1 -n 1 -w 30000",0,True OR wscript.sleep(30000)
Setup.exe is the name of process for which installer/script will wait/loop for specified time interval
Thank you for reading.
No comments:
Post a Comment