Check who currently logged into server from command line?

Posted on 2007-10-15
Last Modified: 2009-07-20
I am at my workstation.  The server I RDP into has all of the connections taken.  My question is this.  Is there a way to check who is currently logged into that server via my command line?
Question by:donnatronious
    LVL 19

    Assisted Solution

    This MS/Sysinternal utility may do the trick for ya:
    LVL 70

    Assisted Solution

    LVL 35

    Accepted Solution

    Run the following command from your workstation:

    Psexec.exe \\computer_name cmd.exe /c SET %username% > Output.txt 2>&1

    Open output.txt and look for username.

    The following script lets you to save the result in a CSV format file for all computers:

    @echo off
    Echo Computer Name, Logged On User Name >> Result.csv
    SET Usr_name=
    For /F Tokens=* %%a In (%srvlist%) Do (
    Set Comp_name=%%a
    Psexec.exe \\%comp_name cmd.exe /c SET %username% > Output.txt 2>&1
    For /f "Tokens=3" %%b in (Output.txt) DO SET Usr_name=%%b
    Echo %Comp_name%, %Usr_name% >> Result.csv
    LVL 9

    Assisted Solution

    Use -

    query user

    ... or -

    query session

    In addition, I recently wrote a script that destroys _INACTIVE_ sessions on Windows Terminal Servers.  It's available here you think if it will beof use -
    LVL 35

    Expert Comment

    by:Nick Sui
    MSE - good job!
    LVL 9

    Expert Comment

    Glad it helped ... feel free to comment back here if you'd like any additional (within reason ;0) features.
    LVL 5

    Expert Comment

    You can also check without run batch  in command prompt type      
    qwinsta /server:IPAddress or Name

    Expert Comment


    Expert Comment

    echo %userdomain%\%username%

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
    On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
    This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now