troubleshooting Question

log off users from remote machine using C#.Net

Avatar of Arikkan
ArikkanFlag for United States of America asked on
Visual Basic.NETC#
1 Comment1 Solution16 ViewsLast Modified:
From the earlier thread (https://www.experts-exchange.com/questions/29216276/Using-VB-Net-or-C-Net-List-active-user-logged-into-a-machine-and-kill-the-session.html) we are able to list users and log off users on local machine when using

IntPtr ptrOpenedServer = WTSOpenServer(ServerName)

[DllImport("wtsapi32.dll", SetLastError = true)]
        static extern bool WTSLogoffSession(IntPtr hServer, int SessionId, bool bWait);

where "ServerName" is "localhost".

However, when specifying the ServerName with the remote machine, we are not able to log off the user.

Could you please let us know if there is a way to log off user on a remote machine on the same network with no firewall restrection between the two machines?  

FYI, we are able to get the list of the logged in users using the code mentioned in the earlier thread.  

Thank you very much.
ASKER CERTIFIED SOLUTION
David H.H.Lee
Digital Marketing (Hospitality)
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros