Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


June 12, 2006

Quickly Detect Who Is Logged On to Your Remote Machines

RSS
View this exclusive article with VIP access -- click here to join |
See More Tips Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

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 log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
No Jobs, No Excitement at Apple's Last Macworld Keynote

Apple CEO Steve Jobs made the right move in skipping out on his company's last appearance at Macworld: In a Tuesday keynote address at the conference, Apple had no interesting new products to sell, opting instead to spend mind-numbing amounts of time on ...

Where is Microsoft NetMeeting in Windows XP?

...

Command Prompt Tricks

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


Task Automation Whitepapers Essential Guide to E-discovery and Recovery for Microsoft Exchange

Continuous Data Protection and Recovery for Microsoft Exchange

Protecting (You and) Your Data with Exchange Server 2007

Related Events 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 Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


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 Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing