title: How to check whether a process is running using VB script?
body: <p>I have the following VB Script which opens a particular window a performs Certain functions in the window.</p>
  
  <pre><code>WScript.Sleep 10000
  Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.Run "Notepad"
  #perform some function
  
  WScript.Sleep 10000
  </code></pre>
  
  <p>I need to repeat same code when notepad is closed so that same notepad is opened again.I tried the following code for that purpose</p>
  
  <pre><code>WScript.Sleep 10000
  Set WshShell = WScript.CreateObject("WScript.Shell")
  If (WshShell.AppActivate("Notepad") = False) then
  ret = True
  End If
  Do while ret 
  WshShell.Run "notepad"
  WScript.Sleep 100
  WshShell.AppActivate "Notepad"
  
  loop
  </code></pre>
  
  <p>But this code keeps on opening the notepad even if the previous notepad isn't closed.</p>