Tuesday, July 20, 2010

VBS Find Who is Logged onto a Remote Machine

This script references the local PC or remote PC and finds the user currently logged on. See below:

ComputerName = InputBox("Enter the name of the computer you wish to query")
who = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""
Set Users = GetObject( who ).InstancesOf ("Win32_ComputerSystem")
for each User in Users
MsgBox "The user name for the specified computer is: " & User.UserName

No comments:

Post a Comment