public void OnTimer(object sender, System.Timers.ElapsedEventArgs args) { string username = getLoginUserName(); if (!_currentUserName.Equals(username)) { eventLog1.WriteEntry("Login user changed, new user: "******"Current Login User: "******"KidsGuard"]; eventLog1.WriteEntry("KidsGuard is not running, start it: " + applicationName, EventLogEntryType.Information); ApplicationLoader.PROCESS_INFORMATION procInfo; ApplicationLoader.StartProcessAndBypassUAC(applicationName, username, eventLog1, out procInfo); } }
bool isKidsGuardRunning(string loginUser) { Process[] processes = Process.GetProcessesByName("KidsComputerGuard"); foreach (Process p in processes) { string owner = ApplicationLoader.GetProcessOwner(p.Id); if (owner.Equals(loginUser, StringComparison.OrdinalIgnoreCase)) { return(true); } } return(false); }