Geeks With Blogs
Caffeinated Coder A Grande, Triple Shot, Non-Fat Core Dump by Russell Ball

I'm doing some work now on an internal web application where I had to logon with an external test account before I could do anything. That got old fast, so I created a powershell script file to automatically launch IE, input the username and password, and click the submit button. I originally tried to do this with WatiN, which provides a much easier interface for controlling the browser than the COM object InternetExplorer.Application, but I couldn't get by the security exceptions explained in this Scott Hanselman post. I then added a keystroke shortcut in WinKey to execute this ps1 file via the hstart utility so that no command window would flash on the screen before the browser window could load. It's probably not the cleanest solution, but it has been a huge time and annoyance saver.

Here's the winkey info

command: <<local path>>\hstart.exe
parameters: /nowindow "C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -command ""&"  'C:\myScriptsDirectory\launchWebApp.ps1'""

...And the powershell script

$psie = new-object -com InternetExplorer.Application
$psie.Navigate2("http://www.someWebApp/")
$psie.visible=1
($psie.document.getElementsByTagName("input") | where { $_.Name -eq "UserID"}).value = "userID"
($psie.document.getElementsByTagName("input") | where { $_.Name -eq "Password"}).value = "password"
($psie.Document.GetElementsByTagname("input") | where { $_.Value -eq "Login"}).click()

 

Posted on Wednesday, July 18, 2007 12:56 PM Technical How-To's , Tools | Back to top


Comments on this post: How To Log On To A Web App With One Keystroke Using Powershell

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Russell Ball | Powered by: GeeksWithBlogs.net