During app debugging (Visual Studio 2012, C#, Excel COM Interop) I usually stop the app from Visual Studio (exception, or the logic is broken). This leaves started from the app Excel instance to hang in the memory. Yes, I can kill it from the Task Manager, but it is pretty annoying. Is there any way to "customize" dependency between Excel and my app process?
I have a Powershell function defined in my profile (C:\Users\{userName}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1)
function Kill-Excel {
$excelInstances = @(Get-Process | Where { $_.Name -Eq "Excel" }).Count
if ($excelInstances -Eq 0) {
"Excel not running"
}
else {
if ($excelInstances -Eq 1) {
"Killing 1 instance of Excel"
}
else {
"Killing $excelInstances instances of Excel"
}
Get-Process | Where { $_.Name -Eq "Excel" } | Kill
}
}
Then I just type Kill-Excel in a Powershell prompt which kills all Excel instances, hidden and visible, on my machine.
Note that this will take down any Excel instances you have open without prompting to save.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With