Stopping a Program Whenever You Feel Like It

by Mar 2, 2010

When you launch a program using Start-Process with -passThru, you will get back the process object representing the started program. You can then use this object later to kill the program whenever necessary.

$notepad = Start-Process notepad -passthru
Start-Sleep 2
Stop-Process -inputObject $notepad

Twitter This Tip! ReTweet this Tip!