Understanding WMI scripting through a specific example-read BIOS information

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.