Launching Programs and Keeping in Touch

Normally, when you launch a program from inside PowerShell, you will lose contact to it. However, by using Start-Process with the -passthru parameter, you will return the process object, which you can then store and later use to check the execution status, error codes, or even kill the program:

$process = Start-Process notepad.exe -passThru
$process
$process.Kill()

Twitter This Tip! ReTweet this Tip!


Posted Oct 26 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.