I'm using C# Windows Forms. Is there an easy way to check if there are no users logged in?
Below is the code I've used for XP, which doesn't seem to work under windows 7 when a user is logged out.
private bool LoggedInUser() { bool loggedIn = true; Process[] aProc = Process.GetProcessesByName("explorer"); if (aProc.Length <= 0) { loggedIn = false; } return loggedIn; }
Thanks :)
[edit]: The program is executed by the task scheduler, not by a user.