一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

WMI学习

时间:2022-07-02 23:28:31 编辑:袖梨 来源:一聚教程网

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 & "ootcimv2")
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 & "ootcimv2")
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:

热门栏目