Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

June 12, 2006 12:00 AM

Quickly Detect Who Is Logged On to Your Remote Machines

Windows IT Pro
InstantDoc ID #50193
Rating: (2)
Downloads
50193.zip

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.

Related Content:

ARTICLE TOOLS

Comments
  • Kyaw
    6 years ago
    Aug 02, 2006

    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.

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.