Get disconnected users and logOff them
Asked Answered
S

2

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.

Sickening answered 22/8, 2013 at 10:13 Comment(0)
F
0

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

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

WTSEnumerateSessions (wtsapi32)

Fronde answered 22/8, 2013 at 11:7 Comment(1)
@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 #5208006Sickening
M
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.

Miscellanea answered 22/8, 2013 at 13:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.