Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


June 12, 2006

Quickly Detect Who Is Logged On to Your Remote Machines

RSS
Subscribe to Windows IT Pro | See More Tips Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

At my company, we perform random scans of remote machines on different subnets to see whether they're creating unnecessary traffic and hence are compromised. Most of the compromised machines have been located in agencies that use our machines. People at the agencies log on with the Active Directory (AD) logon names my company had given them for business needs.

Because we have thousands of machines and thousands of logon names, we needed a way to quickly identify the logon names used on the compromised machines so that we could disable those accounts. So, I wrote a script, WhoLogon.vbs, to detect who is logging on to a remote machine that has been compromised. Listing 1 contains WhoLogon.vbs. As callout A in Listing 1 shows, this script uses the UserName property of Windows Management Instrumentations (WMI's) Win32_ComputerSystem class to obtain the name of the currently logged-on user.

To launch this script, open a command-shell window and type

cscript whologon Machine 
where Machine is the name of the target remote computer. If CScript is your default scripting host, you can simply type
whologon Machine

You need WMI and Windows Script Host (WSH) 5.6 on the machine from which you want to launch WhoLogon.vbs. The remote machines should also have WMI and WSH 5.6 installed. I wrote and tested this script on machines running Windows XP and Windows 2000.

End of Article



Reader Comments
Great, I changed echo lines into one line like:
For Each objItem In colItems
WScript.Echo "Current Login User on Computer " & strComputer & " is " & objItem.UserName

In that way, you don't have to click "OK" multiple times when you call the script without "cscript"
Also note that if a firewall blocks port 135/tcp between admin's machine and remote machine, it won't work.
I wish someone will improve this script with input area for computer name. I guess it shouldn't be too hard to do for experienced script person. (not me;)
Thanks.

ksmoe August 02, 2006 (Article Rating: )


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Understanding File-Size Limits on NTFS and FAT

A general confusion about files sizes on FAT seems to stem from FAT32's file-size limit of 4GB and partition-size limit of 2TB. ...


Task Automation Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Will Your Next Generation Server System Meet Your Infrastructure Optimization Needs?

Continuous Data Protection and Recovery for Microsoft Exchange

Related Events WinConnections and Microsoft® Exchange Connections

7 Ways To Get More From Your SharePoint Deployment Now

Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement