Kill Specific Excel Instances (or other programs)

Stop-Process can very easily kill all instances of Excel or another program. So this line will kill all instances of Excel:

Stop-Process excel ErrorAction SilentlyContinue

You will need the process ID, which you may not have, to kill specific instances. You can filter based on MainWindowTitle, which is the title text of your application, if you want to kill only those instances of Excel that display a certain spreadsheet:

Get-Process excel ea 0 | Where-Object { $_.MainWindowTitle like *report.csv* } | Stop-Process

 

Twitter This Tip! ReTweet this Tip!


Posted Apr 01 2011, 08:00 AM by ps1
Copyright 2012 PowerShell.com. All rights reserved.