
- WINDOWS XP PROCESS MONITOR KILL RESTART MEMORY THRESHOLD HOW TO
- WINDOWS XP PROCESS MONITOR KILL RESTART MEMORY THRESHOLD CODE
- WINDOWS XP PROCESS MONITOR KILL RESTART MEMORY THRESHOLD WINDOWS
Private Declare Function CloseHandle Lib "kernel32" ( _ Private Const PROCESS_QUERY_INFORMATION = &H400&
WINDOWS XP PROCESS MONITOR KILL RESTART MEMORY THRESHOLD CODE
Paste this code into the Form: Option Explicit Add a multiline TextBox Text1 and a Timer Timer1 (which is used to poll the children for completion). To create the demo open a new VB6 Project with a Form. You could enter exit 1234 or somesuch to see this in action. This demo also reports back the exit code of each process that quits. See A Safer Alternative to TerminateProcess(). It is also written to kill any running children when it is terminated, and there are better alternatives to use in most cases. The example is coded to start and repeatedly restart 3 copies of the command shell (trivial sample child program). Ok, here is a super-stripped-down example of a program in VB6 to spawn and monitor programs. CreateProcess gives you the handle directly. The VB6 Shell() function returns a Process ID you can use to call OpenProcess with.

You don't need to go spelunking for processes just to get a handle to child processes that you spawn.


WINDOWS XP PROCESS MONITOR KILL RESTART MEMORY THRESHOLD HOW TO
WINDOWS XP PROCESS MONITOR KILL RESTART MEMORY THRESHOLD WINDOWS
To start interrogating Windows about a particular process ( another VB6 example). I'd start with looking at EnumProcesses ( VB6 example and declaration here) which can be used to gather information about all running processes. If the process cannot be restarted, log and email (emailing is up to you to sort out).There are numerous Windows API functions you can use to do this. Stop the process if the average is >90% and log the eventĪttempt to start the process again and log We monitor for usage >90% over a thirty second period Send-MailMessage # Could not restart process!! The splat is up to you Write-EventLog -LogName "Application" -Source $ProcessName -EventID 3004 -EntryType Information -Message "$ProcessName could not be restarted" -Category 1 Write-EventLog -LogName "Application" -Source $ProcessName -EventID 3003 -EntryType Information -Message "$ProcessName restarted" -Category 1 That will be outside the scope of this reply.

If usage greater than defined threshold/period - restart processĪfter you have the logic, you have to decide how to you want this script to run, scheduletask etc. So the script logic likely looks something like this in layman's terms: I suspect this is true otherwise it will constantly restart. You only want to restart the process if it consumes >90% CPU for a period of time and not a single instantaneous peak? There may be an assumption in the description, can you please verify?
