windows 7 - How do I create a .bat to logoff a specific user from your pc?

06
2014-04
  • user3258523

    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!

  • Answers
  • JSanchez

    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.


  • Related Question

    windows - How to run bat file in background?
  • Jichao

    Possible Duplicate:
    Run a completly hidden batch file

    I have a bat file that open a window and show a lot of information, which bother me a lot. How could I run the bat file in background?


  • Related Answers
  • akira

    There is a program called HSTART which does it easily.

    HSTART /noconsole c:\blah.bat

    you can find it at http://www.ntwind.com/software/utilities/hstart.html

  • icyrock.com