2

Running remote desktops that are acting as specific users on Win7x64.

The main username I'm using is Server. And the rest are as follows

  • hh1
  • hh2
  • hh3
  • etc.

Basically these handheld remote desktop connections sometimes lock up and I want to be able to have the user run a batch file to force logoff specific users from the pc.

I tried using the command shutdown -r -l -f -m \\server\hh1

but that command only seems to work logging off specific computers and not users.

Any help would be greatly appreciated!

2
  • 1
    Hint: Use logoff.exe.
    – gparyani
    Commented Jan 31, 2014 at 20:03
  • Just asked a friend of mine who does stuff like this -- he said that you can't (shouldn't?) do this with a .bat file, and that he would write a "Powershell" script, or some such thing. Commented Jan 31, 2014 at 22:27

1 Answer 1

1

You could use the qwinsta and rwinsta commands to query and disconnect users. Unfortunately, I'm unable to test the remote feature of the commands due to security settings at my current location. But, as per this Tips and Tricks page at Tech Talkz explains, you can definitely do it locally (and remotely, I just can't check if it works as explained)

From a command prompt, perform the following.

Query the connected users:

qwinsta

The command will return 6 columns. We are interested on the SESSIONNAME, USERNAME and ID columns. The SESSIONNAME you're interested in will contain the string rdp-tcp# followed by a number. Match that to the USERNAME you want to disconnect, and note the corresponding ID column. On to the next step.

Disconnect the user:

rwinsta <ID>

Where <ID> is the session ID of the user whom you would like to disconnect.

This works for locally connected RDP sessions (e.g. from the computer you want do disconnect the remote user) but hopefully a remote implementation will work better at your location.

Hope that helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .