- call get_hardware_info
- Function get_hardware_info()
- txt = ""
- Set dic_main = CreateObject("Scripting.Dictionary")
- dic_main.Add "磁盘", "Win32_DiskDrive"
- dic_main.Add "主板", "Win32_BaseBoard"
- dic_main.Add "内存", "Win32_PhysicalMemory"
- dic_main.Add "处理器", "Win32_Processor"
- dic_main.Add "显卡", "Win32_VideoController"
- dic_main.Add "声卡", "Win32_SoundDevice"
- dic_main.Add "网卡", "Win32_NetworkAdapter"
-
- arr_main_Props = Array("Name", "Manufacturer", "Model", "Capacity", "Size", "Speed", "SerialNumber", "ProcessorId")
-
- Set oWMISrvEx = GetObject("winmgmts:root/CIMV2")
- For Each k In dic_main.keys
- txt = txt & vbCrLf & String(50, "=") & vbCrLf
- txt = txt & "[" & k & "]" & vbCrLf
- sWQL = "Select * From " & dic_main(k)
- Set oWMIObjSet = oWMISrvEx.ExecQuery(sWQL)
- For Each oWMIObjEx In oWMIObjSet
- txt = txt & String(30, "=") & vbCrLf
- For Each oWMIProp In oWMIObjEx.Properties_
- If Not IsNull(oWMIProp.Value) Then
- If IsArray(oWMIProp.Value) Then
- For n = LBound(oWMIProp.Value) To UBound(oWMIProp.Value)
- For Each prop In arr_main_Props
- If UCase(prop) = UCase(oWMIProp.Name) Then
- txt = txt & oWMIProp.Name & "(" & n & ")" & ":" & vbCrLf & Trim(oWMIProp.Value(n)) & vbCrLf
- End If
- Next ' prop
- Next
- Else
- For Each prop In arr_main_Props
- If UCase(prop) = UCase(oWMIProp.Name) Then
- txt = txt & oWMIProp.Name & ":" & vbCrLf & Trim(oWMIProp.Value) & vbCrLf
- End If
- Next ' prop
- End If
- End If
- Next
- Next
- txt = txt & vbCrLf
- Next ' k
- fpath = "d:\1.txt"
- CreateObject("Scripting.FileSystemObject").CreateTextFile(fpath, True, False).Write (txt)
- MsgBox "done"
- CreateObject("WScript.Shell").Run fpath
- End Function ' get_hardware_info
复制代码
|