BrainDump
  Home arrow BrainDump arrow Finding Logged on Users and More Scripting...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Finding Logged on Users and More Scripting Secrets
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2009-08-24

    Table of Contents:
  • Finding Logged on Users and More Scripting Secrets
  • More on BSODs
  • Getting the currently logged on user
  • Getting the currently logged on user, method 2
  • Getting the currently logged on user, method 3

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Finding Logged on Users and More Scripting Secrets


    (Page 1 of 5 )

    Welcome back for the fourth installment of Nilpo’s Scripting Secrets. If you missed the first three articles in this series, this is where I present collections of useful script bits that perform useful tasks or present scripting workarounds that might not otherwise be possible in scripting. I’ve got some good stuff in store for you today, so let’s jump right in.

    The first script I want to present to you is a very useful script that will enumerate all of the STOP or bug check errors on a system.  These are commonly referred to as BSODs or errors that result in a Blue Screen Of Death.  This script is especially handy for network administrators who want to poll an entire network of computers for trouble spots, or for technicians who are profiling a troublesome machine.  Heck, it's even good for the average user to inspect a computer for problems they might not even know exist!

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:" _

        & "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")

    This script starts off the same way as any other WMI script.  VBScript's GetObject method is used to connect to the local WMI service in the rootcimv2 namespace.  This is where all of the most common WMI classes are found.

    Set colLoggedEvents = objWMIService.ExecQuery _

        ("Select * from Win32_NTLogEvent Where Logfile = 'System'" _

            & " and SourceName = 'SaveDump'")

    Next we query the System Event Log for entries that have the source name "SaveDump."  This is the name used by Windows any time that it logs a BSOD error.  Of course, your system will have to have logging enabled or it won't be creating event log entries in the first place.  If you're not sure what I'm talking about, don't worry; it's enabled by default.

    For Each objEvent in colLoggedEvents

        Wscript.Echo "Event date: " & objEvent.TimeGenerated

        Wscript.Echo "Description: " & objEvent.Message

    Next

    The WMI query will return a collection of events from the event log.  A simple For loop can be used to move through each of them and print some information about the errors.  The TimeGenerated and Message properties are probably the most useful.  They return the time when the BSOD occurred and the associated error message, respectively.

    More BrainDump Articles
    More By Nilpo


     

    BRAINDUMP ARTICLES

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek