2

I have an issue in a Citrix environment in which a legacy VB application is published on the server. A problem I see is that occasionally it crashes, but the process for the application continues to run. The main problem here is that the rogue process starts to eat up a lot of CPU.

Is there anything I can do to monitor/cleanup these processes in an automated fashion?

Untalented
  • 37
  • 3

1 Answers1

1
foreach($_ in Get-Process) 
{ 
   if($_.ProcessName -eq "notepad" -and $_.Responding -eq $false) 
   { 
       Stop-Process $_ 
   } 
}

Replace notepad with the name of your poorly-written process.

Save that one-liner to a *.ps1 file.

Have Task Scheduler run it every few minutes.

I can't predict exactly how your rogue process behaves. Maybe the processes' Responding property might still be true even if the main window has gone even though the process itself is still running. So you might have to play with it. Maybe the MainWindowTitle property has changed when the process has "crashed" yet is still running. The point is you need to find what sort of behavior does this thing display when it's acting up and how can you detect it.

Ryan Ries
  • 55,011
  • 9
  • 138
  • 197