Tuesday, February 22, 2011

How to manage processes in poweshell

Have you needed to automate little things on your PC. I have a fixed set of things to run in the morning when I start my laptop at work, things like Outlook, IE with yahoo, gmail & facebook, my work diary etc. I find that powershell is very handy at doing this sort of thing. Here's a little script that I use:

[System.Diagnostics.Process]::Start("outlook")
$ie=new-object -com internetexplorer.application
$url1 = "www.google.com/mail/"
$url2 = "www.yahoo.com/mail"
$url3 = "www.facebook.com/yourURL"
$ie.visible=$true
$ie.navigate($url1)
$ie.navigate($url2,0x0800)
$ie.navigate($url3,0x0800)
[System.Diagnostics.Process]::Start("winword.exe", "Full Path to your doc")
[System.Diagnostics.Process]::Start("explorer")

Additionally, check out the following link which explains starting processes in detail:
http://blogs.msdn.com/b/powershell/archive/2007/01/16/managing-processes-in-powershell.aspx

No comments:

Post a Comment