protected override void OnSessionChange(SessionChangeDescription changeDescription) { System.IO.File.AppendAllLines(@"D:INX.TXT", new List<string> { DateTime.Now.ToString() + " ----------" + changeDescription.Reason + " ||| " + changeDescription.SessionId + " 】 " + Environment.UserName }); //base.OnSessionChange(changeDescription); switch (changeDescription.Reason) { case SessionChangeReason.ConsoleConnect: break; case SessionChangeReason.ConsoleDisconnect: break; case SessionChangeReason.RemoteConnect: break; case SessionChangeReason.RemoteDisconnect: break; CanHandleSessionChangeEvent = true; Microsoft.Win32.SystemEvents.SessionEnding+=