title: Scheduled Powershell task can't interact with browser
body: <p>Revised description:</p>
  
  <p>using the suggestion below, I went with the most basic code I could create.  Note that I'm using the Powershell Community Extensions with the "Start-Process" below.  I don't know if that impacts things or not.</p>
  
  <p>I have the below function</p>
  
  <pre><code>function Populate-Notepad
  {
  [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
  Start-Process Notepad 
  [Microsoft.VisualBasic.Interaction]::AppActivate("Untitled")
  [System.Windows.Forms.SendKeys]::SendWait("blahblahblah")
  return
  }
  </code></pre>
  
  <p>Works fine interactively.</p>
  
  <p>I have a function called Parse, which queries a POP account, and if a message is found - take an action.  The action in question is thus ($helptext is defined and it works properly - this is being parsed correctly.)</p>
  
  <pre><code>Switch ($cmd)
  {
  "HELP"     {$text = $helptext}
  "NOTE"     {populate-notepad}
  default    {$msg = $msg + "Invalid command: $command `n"}
  }
  </code></pre>
  
  <p>This does <em>not</em> fire notepad.  If I watch task manager, it never appears to populate.  My guess is that if this can be solved - so can the below problem.</p>
  
  <hr>
  
  <p>I have a powershell script that invokes Firefox and fires a bunch of SendKeys at Firefox (it's a long story, but trying to use web invokation was problematic.)  It works fine interactively, but when a scheduled task runs a powershell script that calls the above powershell script...</p>
  
  <p>Firefox runs...but it's not interactive (so powershell is running and the script is firing.)  In other words, I never see a Firefox window.  I'm not sure if that's important or not, but there is always a firefox.exe in my task manager window.  However, my script always hangs, complaining that it can't find the firefox window.</p>
  
  <p>Like I said, this works interactively; it's using the same credentials via task manager as the regular interactive script does (there's only 1 user other than admin on this box); it's not hidden, and I've tried it as "run with highest privileges" to no avail.</p>
  
  <p>Any thoughts?</p>