|
|
WMI学习 |
|
|
作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站 |
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:

|
|
相关文章:相关软件: |
|