Powered By Blogger

Wednesday, June 4, 2014

wait implementation using START in VBScript

We are much familiar with shell.Run in VBS for executing things in command. Also we have a Wait for the command to complete before continuing execution of the wsh script. Most of the time this flag may not works properly.
So I was struggling to get another option for the same and found a workaround by using START and its WAIT property to achieve my Task.
Here is the Demo:

Set objWshShell = CreateObject("WScript.Shell")
command = "%windir%\system32\cmd /c start /W c:\Windows\System32\inetsrv\appcmd.exe stop apppool /apppool.name:TestAppPool"
objWshShell.Run (command)

(The Demo code will Stop AppPool name TestAppPool)