Kill Specific Excel Instances (or other programs)

by Apr 1, 2011

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!