<p>I'm using <a href="http://en.wikipedia.org/wiki/Windows_Script_Host#Usage" rel="noreferrer">WScript</a> to automate some tasks, by using WScript.Shell to call external programs.</p>

<p>However, right now it does not wait for the external program to finish, and instead moves on. This causes issues because I have some tasks dependent on others finishing first.</p>

<p>I am using code like:</p>

<pre><code>ZipCommand = "7za.exe a -r -y " &amp; ZipDest &amp; BuildLabel &amp; ".zip " &amp; buildSourceDir

Set wshShell = WScript.CreateObject("Wscript.Shell")
wshShell.run ZipCommand
</code></pre>

<p>Is there a way to do this so it blocks until the shell executed program returns?</p>

If you use the "Exec" method, it returns a reference, so you can poll the "Status" property to determine when it is complete.  Here is a sample from
msdn
:
```
```
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec(ZipCommand)

Do While oExec.Status = 0
    WScript.Sleep 100
Loop
```
```