Logoff interactive users in Windows from a service
You could use following P/Invoke calls to achieve this. Below sample works only with Admin Rights [DllImport(“wtsapi32.dll”, SetLastError = true)] static extern bool WTSLogoffSession(IntPtr hServer, int SessionId, bool bWait); [DllImport(“Wtsapi32.dll”)] static extern bool WTSQuerySessionInformation( System.IntPtr hServer, int sessionId, WTS_INFO_CLASS wtsInfoClass, out System.IntPtr ppBuffer, out uint pBytesReturned); [DllImport(“wtsapi32.dll”, SetLastError = true)] static extern IntPtr WTSOpenServer([MarshalAs(UnmanagedType.LPStr)] String … Read more