title: How To Programmatically Wait For Shell Command To Finish Running?
body: <p>I am sending emails in a program like so:</p>
  
  <pre><code>Call Shell(smtpPath, emailInput...)
  </code></pre>
  
  <p>This works great, except if I call the function twice, the function runs the first time, calls the shell command, then the function runs again, and calls the shell command again, but the first shell command is not completed, so there is an error because the second shell command is trying to use the same smtp file as the first one (that is still in use).  </p>
  
  <p>How can I make the function wait until the shell command has finished running?</p>
  
  <p>Addendum: Or is there a way I can see if the file is being used, and if it is, sleep it, then try again?</p>