Option Explicit
' WMIthe object model and the reference manual areMSDN2001in the location:' Platform SDK'->setup and System administration'->windows Management instrumentation'->wmi Reference'->scripting API for WMI
' For Visual Stdio 2008:
' Ms-help://ms. Vscc.v90/ms. Msdnqtr.v90.chs/wmisdk/wmi/wmi_start_page.htm' SWbemLocatorclass is used to connectWMI, and returnwbemservicesObjectDim objswbemlocator Set objswbemlocator=createobject("WbemScripting.SWbemLocator")' WbemServicesclasses are used to perform various operations under a namespaceDim objswbemservices 'namespaces and classes can be usedWMI Object Browserto view, WMI Object Browseris aWMI Toolspart of the. ':http://www.microsoft.com/downloads/details.aspx?familyid=6430f853-1120-48db-8cc5-f2abdc3ed314& Displaylang=en'throughConnectServerconnect to this machine(.)' root\cimv2the namespace hasWindowsthe various software, hardware informationSet objswbemservices=objswbemlocator. ConnectServer (".","root\cimv2") ' SWbemObjectSetclass isSWbemObjectCollection of ObjectsDim objswbemobjectset 'in addition to usingInstancesOf, you can also useSwbemservices.execquerymethod,ExecQueryMethod SupportWQLQuery Language. ' WQLthe query language has aSQLconsistent syntax, very powerful.'we can visualize the thought of eachWMIobject is a database."Table"'like here, we can use"SELECT * from Win32_BIOS". Set objswbemobjectset=objswbemservices. InstancesOf ("Win32_BIOS")Dim strbiosinfo Strbiosinfo=""' SWbemObjectused to denote aWMIObject'here it is aWin32_BIOSinstance, which meansobjSWbemObjectis aWin32_BIOSobject of the classDim objSWbemObject forEach objswbemobject in objswbemobjectset 'below we outputWin32_BIOSthe various properties strbiosinfo = strbiosinfo Span style= ""color: "red& #34; >& "Name:" & objswbemobject . name & vbcrlf _ Span style= ""color: "red& #34; >& & objswbemobject . manufacturer & vbcrlf _ Span style= ""color: "red& #34; >& & objswbemobject . version & vbcrlf _ & "currentlanguage:" & Objswbe Mobject. currentlanguage NextWScript. Echo Strbiosinfo
output on my system:
name:award Modular BIOS v6.00pg
Manufacturer:award Software International, Inc.
Version:gbt-42302e31
currentlanguage:n| Us|iso8859-1
Understanding WMI scripting through a specific example-read BIOS information