0

I am trying to loging into remote server using credentials from command line and checking for the users who got disconnected and I would make them logOff programatically.

This is the way I'm trying to do as of now and bit working.But I'm getting all the users list which I don't want.

So far this is my code for finding out the users on remote desktop who got connected to it.

quser /server:myservername

For Logging Off individually I am using this:

logoff /server:myservername 1 /v

Now my question is If there are more than "1" user how do I find the list of who all are got disconnected and make them LogOff.

coder
  • 13,002
  • 31
  • 112
  • 214

2 Answers2

0

You have to use WMI in vb.net, like;

http://www.pinvoke.net/default.aspx/wtsapi32/WTSEnumerateSessions.html

WTSEnumerateSessions (wtsapi32)

Dennis
  • 1,528
  • 2
  • 16
  • 31
  • @Lectere-What the above does is the same.It logs off only one user..but I want all of them who got disconnected needs to logOff and it was already answered here http://stackoverflow.com/questions/5207506/logoff-interactive-users-in-windows-from-a-service – coder Aug 22 '13 at 11:14
0

From what I can see on my Google searches, quser returns the list of users connected, as well as a session ID column. Simply replace the "1" in your "logoff /server:myservername 1 /v" command with the session you want to log off and it should log that session off instead.

Another option is to set a group policy timer which will logout disconnected users after the timeout period set. Here is a link to an example: http://talkingtechnical.blogspot.com/2009/05/creating-group-policy-to-log-off-remote.html

Setting it at this level means the server will manage the connections rather than rely on a program to run and do so.

Nicholas Post
  • 1,857
  • 1
  • 18
  • 31