| atom0s Moderator
 
  Reputation: 205 
 Joined: 25 Jan 2006
 Posts: 8587
 Location: 127.0.0.1
 
 | 
			
				|  Posted: Sun Dec 01, 2019 2:26 pm    Post subject: Process Monitor (Auto-Terminate CE) |   |  
				| 
 |  
				| This was requested the other day, so figured would toss together a quick and simple example of doing this. 
 This script will automatically terminate CE if a matching process is found running on the system.
 
 You can edit the list by altering the 'procMonNames' table entries'.
 Currently scans once per second, but that can be edited via the 'Interval' value.
 
 
  	  | Code: |  	  | --[[
 Process Monitor [procmon.lua]
 (c) 2019 atom0s
 
 Simple script to monitor the running process list for certain executable names. If a match is found,
 CE will terminate.
 
 Edit the 'procMonNames' to add new processes to monitor.
 Edit the 'Interval' to adjust how often this scans. (Currently once per second.)
 ]]--
 
 -- The list of processes to look for and terminate if found..
 local procMonNames = { 'notepad.exe', 'regedit.exe' };
 
 -- Determines if the given process name exists in the procMonNames table..
 local function hasName(n)
 n = string.lower(n);
 for k, v in ipairs(procMonNames) do
 if (n == v) then
 return true;
 end
 end
 return false;
 end
 
 -- Start a background timer to monitor the process list..
 local procMonTimer = procMonTimer or createTimer();
 procMonTimer.Interval = 1000;
 procMonTimer.OnTimer = function(t)
 -- Obtain the current process list..
 local procs = getProcesslist();
 
 -- Check for bad processes to kill CE..
 for k, v in pairs(procs) do
 if (hasName(v)) then
 closeCE();
 end
 end
 end
 procMonTimer.setEnabled(true);
 
 | 
 
 Save as procmon.lua inside of your CE autorun folder.
 _________________
 
 - Retired. |  |