Wednesday, April 27, 2011

Different ways to open application/programs in powershell

I wanted to test start-up speed of Firefox, IE and Chrome. So I wanted to write a small script to open all these browsers in same time and see which browser opens faster.

If I wanted to write it in batch file, it would be something like this.

start firefox.exe www.google.com
start iexplore.exe www.google.com
start chrome.exe www.google.com

You can do the same thing in Powershell like this,

#Start-Process starts application/script file
Start-Process "firefox.exe" "www.google.com"
Start-Process "iexplore.exe" "www.google.com"
Start-Process "chrome.exe" "www.google.com"
#Or Use .Net API to open application
[System.Diagnostics.Process]::Start("firefox.exe","www.google.com")
[System.Diagnostics.Process]::Start("iexplore.exe","www.google.com")
[System.Diagnostics.Process]::Start("chrome.exe","www.google.com") 

By the way winner is Chrome, I love you Firefox, but you have to start up faster :(

0 Comments: