Created
September 29, 2015 11:44
-
-
Save jhorsman/07156b3370c7a9c58a54 to your computer and use it in GitHub Desktop.
Kill IntelliJ java processes (when stopping an Tomcat debug session in IntelliJ some processes were not killed and kept blocking port 1099)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get-WmiObject Win32_Process -Filter "name = 'java.exe'" | select ProcessId, ThreadCount, CommandLine | |
$processes = Get-WmiObject Win32_Process -Filter "name = 'java.exe'" | |
foreach($proc in $processes) | |
{ | |
if($proc.CommandLine.Contains("IntelliJ")) | |
{ | |
Write-Host "stopping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..." | |
Stop-Process -F $proc.ProcessId | |
} else | |
{ | |
Write-Host "skipping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment