Revised description:
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.
I have the below function
function Populate-Notepad
{
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
Start-Process Notepad
[Microsoft.VisualBasic.Interaction]::AppActivate("Untitled")
[System.Windows.Forms.SendKeys]::SendWait("blahblahblah")
return
}
Works fine interactively.
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.)
Switch ($cmd)
{
"HELP" {$text = $helptext}
"NOTE" {populate-notepad}
default {$msg = $msg + "Invalid command: $command `n"}
}
This does not 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.
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...
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.
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.
Any thoughts?
notepad.exefor example.