WMI学习

类别:Asp 点击:0 评论:0 推荐:
WMI:Windows Management Instrument
WMI Tasks:
1、Accounts and Domains
①determine the domain in which a computer belongs:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings 
    msgbox "System Name: " & objComputer.Name
    msgbox "Domain: " & objComputer.Domain
Next
②determine whether a computer is a server or a workstation:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
    ("Select DomainRole from Win32_ComputerSystem")
For Each objComputer in colComputers
    Select Case objComputer.DomainRole
        Case 0
            strComputerRole = "Standalone Workstation"
        Case 1       
            strComputerRole = "Member Workstation"
        Case 2
            strComputerRole = "Standalone Server"
        Case 3
            strComputerRole = "Member Server"
        Case 4
            strComputerRole = "Backup Domain Controller"
        Case 5
            strComputerRole = "Primary Domain Controller"
    End Select
    msgbox strComputerRole
Next
③determine the computer name:

本文地址:http://com.8s8s.com/it/it8319.htm