title: VBScript /w AppActivate for multiple instances of an application
body: <p>We have an application that will minimize itself to the top-left corner of the screen when you disconnect from your VMware View desktop. So I wrote the following VBS that will activate the app and maximize it that works fine.</p>
  
  <pre><code>Set objShell = CreateObject("WScript.Shell")
   objShell.AppActivate "notepad"
  
  objShell.SendKeys "% r"
  
  objShell.SendKeys "% x"
  </code></pre>
  
  <p>But some users have multiple instances of the same app open. So I'm wondering how to get this script to execute for every instance of the application? I'm assuming I'll have to key off of the PID, since each instance will have its own PID, but I'm unsure how to do this.</p>
  
  <p>Thanks,
  Brian</p>