I originally wrote this script to lower the priority level of antivirus scanners. If scanning was done while I was using the computer, the system became somewhat unresponsive. I also wrote a .reg file that allows Proc_Watch to run at system startup.
It takes three arguments:
1) Time interval (in seconds) to wait inbetween checking for the processes
2) Priority 0 - 5 (0 lowest, 3 normal, 5 highest)
3,4,5,...) List of process names to check for, if one is found, it's priority will be changed to that of argument #2.
Example:
Proc_Watch 30 0 notepad.exe firefox.exe acrotray.exe
I have posted the code as well as including it as an attachment.
-John
#cs Proc_Watch Set priority of a given list of processes to the lowest possible setting Originally written to help antivirus scanners not hog the cpu -John Taylor July-30-2005 Command-line options (all mandatory): 1) time interval in seconds to check for the list of processes 2) priority 3,4,5,...) list of processes to check for The argument which determines what priority to set 0 - Idle/Low 1 - Below Normal (Not supported on Windows 95/98/ME) 2 - Normal 3 - Above Normal (Not supported on Windows 95/98/ME) 4 - High 5 - Realtime (Use with caution, may make the system unstable) #ce #include <GUICONSTANTS.au3> #notrayicon Opt ("GUIOnEventMode", 1) Opt ("MustDeclareVars", 1) Opt ("RunErrorsFatal", 0 ) Dim $usage = "Command-line options (all mandatory):" & @CR & "1) time interval in seconds to check for the list of processes" & @CR & "2) priority" & @CR & "3,4,5,...) list of processes to check for" & @CR & "" & @CR & "The argument which determines what priority to set" & @CR & "0 - Idle/Low" & @CR & "1 - Below Normal (Not supported on Windows 95/98/ME)" & @CR & "2 - Normal" & @CR & "3 - Above Normal (Not supported on Windows 95/98/ME)" & @CR & "4 - High" & @CR & "5 - Realtime (Use with caution, may make the system unstable)" & @CR & @CR & "Example:" & @CR & @AutoItExe & " 30 0 firefox.exe notepad.exe acrotray.exe" if int($CmdLine[0]) < 3 Then MsgBox(0, "Process_Check usage:", $usage); Exit EndIf Dim $interval = int($CmdLine[1]) Global $priority = int($CmdLine[2]) Global $plist[$CmdLine[0] - 2] Global $i for $i = 3 to $CmdLine[0] ;MsgBox(0, $i, $CmdLine[$i]) $plist[$i - 3] = $CmdLine[$i] Next AdlibEnable("Process_Watch", $interval*1000) _ReduceMemory() while 1 sleep (1000) WEnd Func Process_Check() for $i = 0 to UBound($plist) - 1 ;MsgBox(0,$i,$plist[$i]) if ProcessExists($plist[$i]) Then ;MsgBox(0,"Process_Check", $plist[$i] & " set to " & $priority) ProcessSetPriority($plist[$i], $priority) EndIf Next _ReduceMemory() EndFunc Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc;==> _ReduceMemory()
Attached Files
Edited by jftuga, 15 March 2007 - 02:01 PM.





