Skip to content

Instantly share code, notes, and snippets.

@jhorsman
Created September 29, 2015 11:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhorsman/07156b3370c7a9c58a54 to your computer and use it in GitHub Desktop.
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)
#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