protected override void OnStart(string[] args) { ScamEventLog.WriteEntry("Starting termination guard"); // Set up a timer that triggers every 5 seconds. System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 5000; // 5 seconds timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer); timer.Start(); }
public void OnTimer(object sender, System.Timers.ElapsedEventArgs args) { // TODO: Insert monitoring activities here. Process[] pname = Process.GetProcessesByName("ScamBooter"); if (pname.Length == 0) { System.IO.Directory.SetCurrentDirectory("C:\\Users\\zoyme\\AppData\\Local\\ScamBooter"); ProcessExtensions.StartProcessAsCurrentUser("C:\\Users\\zoyme\\AppData\\Local\\ScamBooter\\ScamBooter.exe"); ScamEventLog.WriteEntry("Process was terminated, restarting process", EventLogEntryType.Information, eventId++); } }
protected override void OnStop() { ScamEventLog.WriteEntry("Stopping termination guard."); }