首页  编辑  

使用WMI SQL语句查询系统硬件信息

Tags: /超级猛料/Hardware.硬件相关/   Date Created:
请查阅MSDN中关于WMI Scripting Primer的部分,极其有用的。或者搜索:winmgmts
例子:
strComputer = "."
strNamespace = "\root\cimv2"
strClass = "Win32_Service"
Set objSWbemServices = GetObject("winmgmts:\\" & strComputer & strNamespace)
Set colSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass)
For Each objSWbemObject In colSWbemObjectSet
   WScript.Echo "Display Name: " & objSWbemObject.DisplayName
   WScript.Echo "State:        " & objSWbemObject.State
   WScript.Echo "Start Mode:   " & objSWbemObject.StartMode
Next

Visual Basic and VBScript support the following syntax:
Set objinst = GetObject("WinMgmts:Win32_LogicalDisk")
Windows Script Host (WSH) also supports:
<OBJECT id="myLocator" progid="WbemScripting.SWbemLocator"></OBJECT>