In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you about how Hardware_Info.vbs gets hardware information. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The code is as follows:
'Hardware_Info.vbs v1.1 BY: fastslz
On Error Resume Next
Dim WMI,WS,Fso
Set WMI = GetObject ("Winmgmts: {impersonationLevel=impersonate}!\\.\ root\ cimv2")
Set cOSs = WMI.ExecQuery ("Select * from Win32_OperatingSystem")
For Each oOS in cOSs
OSx = oOS.Caption & "& oOS.CSDVersion & vbCrLf
Next
BBx= "- motherboard information -" & vbCrLf
Set Board = WMI.InstancesOf ("Win32_BaseBoard")
Set Bios = WMI.InstancesOf ("Win32_Bios")
For Each oBoard In Board
BBx = BBx _
& "Motherboard name:" & oBoard.Product & vbTab & oBoard.Version & vbCrLf _
& "manufacturer:" & oBoard.Manufacturer & vbCrLf
Next
For Each oBios In Bios
BBx = BBx _
& "BIOS manufacturer:" & oBios.Manufacturer & vbCrLf _
& "BIOS date:" & FormatDateTime (wDate (Trim (oBios.ReleaseDate)), 1) & vbCrLf _
& "BIOS version:" & oBios.SMBIOSBIOSVersion & vbCrLf _
& "OEM version:" & oBios.Version & vbCrLf
Next
Set Bios = Nothing:Set Board = Nothing
CPUx = "- processor Information -" & vbCrLf
Set CPUs = WMI.InstancesOf ("Win32_Processor")
Set Caches = WMI.InstancesOf ("Win32_CacheMemory")
For Each ObjCPU In CPUs
MCS = ObjCPU.MaxClockSpeed: CCS = ObjCPU.CurrentClockSpeed
If ObjCPU.MaxClockSpeed Mod 2 = 1 Then MCS = CCS + 1
If ObjCPU.CurrentClockSpeed Mod 2 = 1 Then CCS = CCS + 1
OC = QOC (CCS,MCS)
If (OC-MCS) > 10 and (OC-MCS) > 0 Then OCLC = "overclocking ratio:" & FormatPercent ((OC-MCS) / MCS)
If (OC-MCS)
< -10 and (OC-MCS) < 0 Then OCLC = " 降频比率: " & FormatPercent((OC-MCS)/MCS) CPUx = CPUx _ & "CPU 名称: " & Trim(ObjCPU.Name) & vbCrLf _ & "CPU 构架: " & ObjCPU.Description & vbCrLf _ & "制造厂商: " & ObjCPU.Manufacturer & vbCrLf _ & "接口规格: " & ObjCPU.SocketDesignation & vbCrLf _ & "CPU 数量: " & ObjCPU.CpuStatus & vbCrLf _ & "核心数量: " & ObjCPU.NumberOfCores & vbCrLf _ & "线程数量: " & ObjCPU.NumberOfLogicalProcessors & vbCrLf _ & "地址位宽: " & ObjCPU.AddressWidth & " Bit" & vbCrLf _ & "数据位宽: " & ObjCPU.DataWidth & " Bit" & vbCrLf _ & "CPU 电压: " & ObjCPU.CurrentVoltage / 10 & "V" & vbCrLf _ & "外部频率: " & ObjCPU.ExtClock & " MHz" & vbCrLf _ & "当前频率: " & OC & " MHz" & OCLC & vbCrLf _ & "原始频率: " & MCS & " MHz" & vbCrLf _ & "CPU 使用: " & ObjCPU.LoadPercentage & "%" & vbCrLf Next Function QOC(CCS,MCS) If CCS = MCS Then Set wReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") wReg.GetDWORDValue &H80000002,"HARDWARE\DESCRIPTION\System\CentralProcessor\0","~MHz",strValue OC = strValue :Set wReg = Nothing Else OC = CCS End If QOC = OC :If QOC Mod 2 = 1 Then QOC = QOC + 1 End Function For Each ObjCache In Caches If objCache.MaxCacheSize >0 Then
Select Case objCache.Purpose
Case "L1-Cache"
CPUx = CPUx & "first-level cache: & objCache.MaxCacheSize &" KB (L1 data + L1 cache) & vbCrLf
Case "L2-Cache"
CPUx = CPUx & "second-level cache:" & objCache.MaxCacheSize & "KB" & vbCrLf
Case "L3-Cache"
CPUx = CPUx & "three-tier cache:" & objCache.MaxCacheSize & "KB" & vbCrLf
End Select
End If
Next
Set Caches = Nothing:Set CPUs = Nothing
Memx = "- memory information -" & vbCrLf
Set Memorys = WMI.InstancesOf ("Win32_PhysicalMemory")
Set MemKY = WMI.InstancesOf ("Win32_OperatingSystem")
For Each aKY In MemKY
ZL = aKY.TotalVisibleMemorySize
KY = aKY.FreePhysicalMemory
Next
Mems = 0:Memc = 0
Types = Array ("Unknown", "Other", "DRAM", "Synchronous DRAM", "Cache DRAM", "EDO", "EDRAM", "VRAM", "SRAM", "RAM", _
"ROM", "Flash", "EEPROM", "FEPROM", "EPROM", "CDRAM", "3DRAM", "SDRAM", "SGRAM", "RDRAM", "DDR", "DDR2")
For Each Mem In Memorys
For I = 0 To UBound (Types)
If Mem.MemoryType = i Then MemType = Types (I): End If
Next
For j = 0 To 6
Select Case Mem.Tag
Case "Physical Memory" & j
Mems = Mems+ (Mem.Capacity)
Memx = Memx & "slot" & Mem.DeviceLocator & ":" & Round (Mem.Capacity/1048576) & "MB" _
& MemType & "-" & Mem.Speed & "MHz" & "data bandwidth" & Mem.DataWidth _
& "Bit" & "Total bandwidth" & Mem.TotalWidth & "Bit" & vbCrLf
End Select
Next
Next
Memx = Memx _
& "memory installation:" & Round (Mems/1048576) & "MB" & vbCrLf _
& "Total memory:" & Round (ZL/1024) & "MB" & vbCrLf _
& "memory available:" & Round (KY/1024) & "MB" & vbCrLf _
& "memory usage:" & FormatPercent ((ZL-KY) / ZL) & vbCrLf
Set Memorys = Nothing:Set MemKY = Nothing
Vx= "- Video Card Information -" & vbCrLf
Set cVID = WMI.ExecQuery ("SELECT DeviceID FROM Win32_VideoController")
For Each oVID In cVID
Set Video = WMI.ExecQuery ("SELECT * FROM Win32_VideoController WHERE DeviceID='" & oVID.DeviceID & "'")
For Each oVideo In Video
Vx = Vx _
& "Video card name:" & oVideo.Name & vbCrLf _
& "manufacturer:" & oVideo.AdapterCompatibility & vbCrLf _
& "physical Video memory:" & Round (oVideo.AdapterRAM/1048576) & "MB" & vbCrLf _
& "display mode:" & oVideo.CurrentHorizontalResolution & "X" _
& oVideo.CurrentVerticalResolution & "" _
& oVideo.CurrentBitsPerPixel & "Bit" _
& oVideo.CurrentRefreshRate & "Hz" & vbCrLf
Next
Next
Set Video = Nothing:Set cVID = Nothing
Dx= "- hard disk Information -" & vbCrLf
Set IDE = WMI.ExecQuery ("Select * from Win32_DiskDrive WHERE InterfaceType='IDE'")
Set cPPP = WMI.ExecQuery ("SELECT * FROM Win32_PerfRawData_PerfDisk_PhysicalDisk")
For Each oIDE In IDE
For I = 0 To IDE.Count
Select Case oIDE.Index
Case i
For Each oPPP In cPPP
If InStr (oPPP.Name, I) Then vName = oPPP.Name
Next
Dx = Dx & "hard disk" & I & "Model: & oIDE.Caption & vbCrLf _
& vbTab & "nominal capacity:" & Round (oIDE.Size/1000000000) & "GB" & vbCrLf _
& vbTab & "actual capacity:" & Round (oIDE.Size/1073741824) & "GB" & vbCrLf _
& vbTab & "number of cylinders:" & oIDE.TotalCylinders & vbCrLf _
& vbTab & "number of heads:" & oIDE.TotalHeads & vbCrLf _
& vbTab & "number of sectors per sector:" & oIDE.SectorsPerTrack & vbCrLf _
& vbTab & "sector size:" & oIDE.BytesPerSector & vbCrLf _
& vbTab & "Total sectors:" & oIDE.TotalSectors & vbCrLf _
& vbTab & "Partition status:" & vName & vbCrLf
DevID = Replace (oIDE.DeviceID, "\", "\\")
Set cDP = WMI.ExecQuery ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=" & DevID & "}" _
& "WHERE AssocClass = Win32_DiskDriveToDiskPartition")
For Each oDP In cDP
Set cLD = WMI.ExecQuery ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=" & oDP.DeviceID & "}" _
& "WHERE AssocClass = Win32_LogicalDiskToPartition")
For Each oLD In cLD
Dx = Dx _
& vbTab & oLD.DeviceID & "& Left (oLD.VolumeName&", 11) & Left (oLD.FileSystem&", 6) &" Total: "_
& Right ("& Round (oLD.Size/1073741824,1), 6) &" GB available: "_
& Right ("& Round (oLD.FreeSpace/1073741824,1), 6) &" GB used: "_
& Right ("& Round ((oLD.Size-oLD.FreeSpace) / 1073741824), 6) &" GB "& vbCrLf
Next
Next
End Select
Next
Next
Set cLD = Nothing:Set cDP = Nothing:Set IDE = Nothing:Set cDP = Nothing:Set cPPP = Nothing
Sx= "- Sound Card Information -" & vbCrLf
Set cSD = WMI.ExecQuery ("SELECT * FROM Win32_SoundDevice")
For Each oSD In cSD
Sx = Sx & "name of sound card: & oSD.ProductName & vbCrLf
Next
Set cSD = Nothing
Nx= "- Network Card Information -" & vbCrLf
Set cNet = WMI.ExecQuery ("Select * from Win32_NetworkAdapter WHERE PhysicalAdapter = 'TRUE'")
If CStr (cNet.Count)
< 0 Then Set cNet = WMI.ExecQuery("Select * from Win32_NetworkAdapter WHERE PNPDeviceID Like 'PCI%%' or PNPDeviceID Like 'USB%%'") For Each oNet In cNet If oNet.NetConnectionStatus >0 Then
Nx = Nx & "Network card name:" & oNet.Name & vbCrLf
Else
Nx = Nx & "Network card name:" & oNet.Name & vbCrLf
End If
Next
Else
For Each oNet In cNet
If oNet.NetEnabled = TRUE Then
Nx = Nx & "Network card name:" & oNet.Name & vbTab & "active status" & vbCrLf
Else
Nx = Nx & "Network card name: & oNet.Name & vbTab &" idle status "& vbCrLf
End If
Next
End If
Set cNet = Nothing
If (Lcase (Right (Wscript.FullName,11)) = "wscript.exe") Then
MsgBox OSx & BBx & CPUx & Memx, "Hardware_Info.vbs v1.0 BY: fastslz"
MsgBox Vx & Sx & Nx, "Hardware_Info.vbs v1.0 BY: fastslz"
MsgBox Dx, "Hardware_Info.vbs v1.0 BY: fastslz"
MsgN = MsgBox ("Save to file?" , 32, 4, "Hardware_Info.vbs v1.0 BY: fastslz")
If MsgN = 6 Then JZCSx = JZCS: wInfo
Else
WScript.Echo OSx & BBx & CPUx & Memx & Vx & Sx & Nx & Dx
End If
Set WMI = Nothing
Sub wInfo ()
Set WS = CreateObject ("WScript.Shell")
Set Fso = CreateObject ("Scripting.FileSystemObject")
AFile = WS.CurrentDirectory & "\" & WS.ExpandEnvironmentStrings ("% COMPUTERNAME%") & "_ Hardware_Info.txt"
Set HInfo = Fso.CreateTextFile (aFile, True)
HInfo.WriteLine "Hardware_Info.vbs BY: fastslz"
HInfo.WriteLine OSx & BBx & CPUx & Memx & Vx & Sx & Nx & Dx & JZCSx
HInfo.Close
WS.Run Chr (34) & aFile & Chr (34)
Set WS = Nothing:Set Fso = Nothing:Set HInfo = Nothing
End Sub
Function wDate (nD)
If Not IsNull (nD) Then
WDate = CDate (Mid (nD,5,2) & "/" & Mid (nD,7,2) & "/" & Left (nD,4) & "& Mid (nD,9,2) &": & Mid (nD,11,2) & ": & Mid (nD,13,2))
End If
End Function
Function JZCS ()
NumMsg = vbCrLf & "- simple CPU benchmark -" & vbCrLf
Dim I,T1,T2,Tempvalue,aRunTime,bRunTime
T1 = Timer ()
For I = 1 To 2000000
Tempvalue= 2 ^ 0.5
Next
ARunTime = FormatNumber ((T2-T1) * 1000pm 2)
NumMsg = NumMsg & "time required for the 2 million square calculation of CPU" & aRunTime& "milliseconds" & vbCrLf
T1 = Timer ()
Tempvalue= 1 + 1
Next
T2 = Timer ()
BRunTime = FormatNumber ((T2-T1) * 1000pm 2)
NumMsg = NumMsg & "time required for CPU 6 million addition calculations" & bRunTime& "milliseconds" & vbCrLf
JZCS = NumMsg
End Function
Cmd calling method
The code is as follows:
@ echo off
For / f "delims=*"% an In ('Cscript / / Nologo "Hardware_Info.vbs" ^ | find ":"') do echo% a
Create a new Backup folder on the first partition of the second hard disk
For / f "tokens=2,*" an In ('Cscript / / Nologo "Hardware_Info.vbs" ^ | findstr "Partition status") do (
If% a million dollars for / f "tokens=1"% I In ("% b") do MD "% I\ Backup")
Pause
Thank you for reading! This is the end of the article on "how to get hardware information from Hardware_Info.vbs". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un