title: Is there a better way to check for Virtual Directory and if not, Create it?
body: <p>I have some vbscript code I use to set paths to virtual directories when a developer switches his/her environment to work on another project. Currently, we try to set the path, and if there's an error, we create it. It just smells funny. Is there a way to check if a Virtual Directory exists? And if not, create it?</p>
  
  <pre><code>set objIIS = GetObject("IIS://" &amp; strComputer &amp; "/W3SVC/1/ROOT/SomeWeb")
  objIIS.Path = strNewPath &amp; "\SomeWeb"
  objIIS.SetInfo
  
  If Err.Number =  NOT_FOUND Then
      sVirtPath = strNewPath &amp; "\SomeWeb"
  CreateVirtualDirectory "SomeWeb", sVirtPath, true
  Err.Clear
  End If
  </code></pre>
  
  <p>This works just fine, but something tells me, there must be a better way. Does anyone have any suggestions? How do I check for the existence of a Virtual Directory? Any feedback is appreciated.</p>
  
  <p>Thanks for any pointers.<br>
  Cheers,<br>
  ~ck in San Diego</p>