Reputation: 14938
Sometimes I have one or more web services running in the Visual Studio debugger. They each have a chrome browser open with a custom profile. If I close those browser windows, Visual Studio stops debugging. Then I have "regular" chrome tabs running.
Sometimes I want to kill all the chrome processes besides the ones that are controlled by the Visual Studio debugger. Is there a way to filter them?
Upvotes: 1
Views: 872
Reputation: 14938
Chrome processes stared by Visual Studio have a custom data directory in %USER_PROFILE%\AppData\Local\Microsoft\VisualStudio
. This can be determined by the command line argument of the chrome process. For my machine it is:
--user-data-dir=C:\Users\justin.dearing\AppData\Local\Microsoft\VisualStudio\15.0_cf8b40b5\WebTools\ChromeUserData_B1BEBFE6_D97D9A83-D0C1-4583-B7FA-995316F620C4
You can't get the command line with Get-Process. You need to use the WMI or CIM cmdlets to get the Win32 WMI class, e.g. Get-CimInstance Win32_Process
. The following oneliner works.
Get-CimInstance Win32_Process -Filter "name = 'chrome.exe' and NOT(commandline LIKE '%Microsoft\\Visual%') " | Select ProcessId | %{ kill $_.processid }.
Upvotes: 2