Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse WMI to get lots of information about the computer system in Visual Basic 2005
DescriptionThis example shows how to use WMI to get lots of information about the computer system in Visual Basic 2005.
KeywordsWMI, Visual Basic 2005, AdminPasswordStatus, AutomaticManagedPagefile, AutomaticResetBootOption, AutomaticResetCapability, BootOptionOnLimit, BootOptionOnWatchDog, BootROMSupported, BootupState, Caption, ChassisBootupState, CreationClassName, CurrentTimeZone, DaylightInEffect, Description, DNSHostName, Domain, DomainRole, EnableDaylightSavingsTime, FrontPanelResetStatus, InfraredSupported, InitialLoadInfo, InstallDate, KeyboardPasswordStatus, LastLoadInfo, Manufacturer, Model, Name, NameFormat, NetworkServerModeEnabled, NumberOfLogicalProcessors, NumberOfProcessors, OEMLogoBitmap, OEMStringArray, PartOfDomain, PauseAfterReset, PCSystemType, PowerManagementCapabilities, PowerManagementSupported, PowerOnPasswordStatus, PowerState, PowerSupplyState, PrimaryOwnerContact, PrimaryOwnerName, ResetCapability, ResetCount, ResetLimit, Roles, Status, SupportContactDescription, SystemStartupDelay, SystemStartupOptions, SystemStartupSetting, SystemType, ThermalState, TotalPhysicalMemory, UserName, WakeUpType, Workgroup
CategoriesAPI, Windows
 
When the program starts, it executes the query WMI "SELECT * FROM Win32_OperatingSystem." It loops through the results and calls subroutine GetValue for each of the many system parameters that should be available. The following code shows just a couple of the GetValue calls.
 
Dim os_searcher As New ManagementObjectSearcher("SELECT * " & _
    "FROM Win32_OperatingSystem")
For Each mobj As ManagementObject In os_searcher.Get()
    GetValue(mobj, "AdminPasswordStatus")
    GetValue(mobj, "AutomaticManagedPagefile")
    GetValue(mobj, "AutomaticResetBootOption")
    ...
Next mobj
 
Subroutine GetValue fetches a property by name from the ManagementObject and adds its name and value to a ListView control.
 
Private Sub GetValue(ByVal mobj As ManagementObject, ByVal _
    property_name As String)
    Dim value As String
    Try
        value = mobj(property_name).ToString()
    Catch ex As Exception
        value = "*** Error: " & ex.Message
    End Try

    lvwResults.Items.Add(property_name).SubItems.Add(value)
End Sub
 
This example fetches these properties:

  • AdminPasswordStatus
  • AutomaticManagedPagefile
  • AutomaticResetBootOption
  • AutomaticResetCapability
  • BootOptionOnLimit
  • BootOptionOnWatchDog
  • BootROMSupported
  • BootupState
  • Caption
  • ChassisBootupState
  • CreationClassName
  • CurrentTimeZone
  • DaylightInEffect
  • Description
  • DNSHostName
  • Domain
  • DomainRole
  • EnableDaylightSavingsTime
  • FrontPanelResetStatus
  • InfraredSupported
  • InitialLoadInfo
  • InstallDate
  • KeyboardPasswordStatus
  • LastLoadInfo
  • Manufacturer
  • Model
  • Name
  • NameFormat
  • NetworkServerModeEnabled
  • NumberOfLogicalProcessors
  • NumberOfProcessors
  • OEMLogoBitmap
  • OEMStringArray
  • PartOfDomain
  • PauseAfterReset
  • PCSystemType
  • PowerManagementCapabilities
  • PowerManagementSupported
  • PowerOnPasswordStatus
  • PowerState
  • PowerSupplyState
  • PrimaryOwnerContact
  • PrimaryOwnerName
  • ResetCapability
  • ResetCount
  • ResetLimit
  • Roles
  • Status
  • SupportContactDescription
  • SystemStartupDelay
  • SystemStartupOptions
  • SystemStartupSetting
  • SystemType
  • ThermalState
  • TotalPhysicalMemory
  • UserName
  • WakeUpType
  • Workgroup
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated