Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Help] How do you see who is logged in?

Featured Replies

Is there a way, from the command line, to find out who is logged into a computer remotely? I can telnet into a machine to get a command prompt on that machine, but I don't know the command to see who is logged in. I'm looking for the Windows equivilent to the Unix who command, if that helps.


Would you be interested in a vb script, or strictly command line?

  • Author

It doesn't matter as long as it prints out on the command line, otherwise I will not be able to see it. That is the only requirement: must display on the command line. I'm doing this remotely through telnet. If you have a vbscript, then I could probably modify it to print on the command line using wscript.echo...

Here's the script. Hope you can make it work for you.

Option Explicit

Dim objWMIService, objComputer, colComputer

Dim strLogonUser, strLogonUser1, strComputer

strComputer = "."

strComputer = InputBox("Enter Computer name", _

"Find Logon User", strComputer)

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" _

& strComputer & "\root\cimv2")

Set colComputer = objWMIService.ExecQuery _

("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer

If not objComputer.UserName = "" Then

strLogonUser = Split(objComputer.UserName,"\")

strLogonUser(1) = UCase(Left(strLogonUser(1),1))_

& Trim(Mid(strLogonUser(1),2,20))

Wscript.Echo strLogonUser(1) & " is logged on at " _

& strComputer

Else

Wscript.Echo "No one is currently logged on at " _

& strComputer

End If

Next

  • Author

Ah yes, that was exactly what I was looking for. :thumbup Here's the modified version of your script:

Option Explicit

Dim objWMIService, objComputer, colComputer
Dim strLogonUser, strLogonUser1, strComputer

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

Wscript.Echo "Users currently logged in" & vbNewLine
For Each objComputer in colComputer
If not objComputer.UserName = "" Then
strLogonUser = Split(objComputer.UserName,"\")
strLogonUser(1) = UCase(Left(strLogonUser(1),1)) & Trim(Mid(strLogonUser(1),2,20))
Wscript.Echo vbTab & strLogonUser(1)
Else
Wscript.Echo vbTab & "None."
End If
Next
Wscript.Echo vbNewLine & "Done." & vbNewLine

And when I run it, I get this:

E:\Deployment\Development\temp>cscript.exe login.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Users currently logged in

Administrator

Done.


E:\Deployment\Development\temp>

Maelstorm - Glad it worked for you and thanks for the modified code. :hello:

you can just use psloggedon from the pstools pack and run it from your own machine (assuming you have an account on the pc, or know the admin pass!)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.