<div class="blockcode">
<pre class="brush:vb;">
Const MyName = "Windows硬件检视工具(测试版) --by:Rex.Pack(雷克斯.派)"
If Not LCase(Replace(WScript.FullName, WScript.Path & "\", "")) = "cscript.exe" Then
Set WS = CreateObject("WScript.Shell")
WS.Run "CMD /c mode con: cols=115 & Color 0A & Title " & MyName & " & CScript //nologo """ & WScript.ScriptFullName & """"
WScript.Quit
End If
'----初始化
Set SD = CreateObject("Scripting.Dictionary")
SD.CompareMode = vbTextCompare
Set S = New BaseStr
Set PC = New BasePC
Set WMI = GetObject("Winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
CmdArr = Split(" OS CPU Board Memory Video Disk USB CacheMemory NetWork BIOS Sound Battery PortableBattery" & " S1 S2 S3 S4")
With SD
.Add "?", "Call Menu"
.Add "e", "WScript.Quit"
For I = 1 To 17
.Add CStr(I), CmdArr(I)
Next
.Add "a", "1-6"
.Add "b", "7-9"
.Add "c", "10-13"
.Add "d", "14-17"
End With
Echo MyName
Call Menu
Call Main
'----CO
Sub Menu()
Echo "[设备列表]"
Echo " 常用组 A: 1.OS 2.CPU 3.主板 4.内存 5.显卡 6.硬盘"
Echo " 次级组 B: 7.USB 8.缓存 9.网卡"
Echo " 酱油组 C: 10.BIOS 11.声卡 电池(12.内部 13.便携)"
Echo "[测试CPU]"
Echo " 测试组 D: 14.变量幂次方运算 15.字符叠合 16.加法计算 17.叠加计算"
End Sub
Sub Main()
Print ">": GetNum = Trim(InPut)
With SD
If .Exists(GetNum) Then
If IsNumeric(GetNum) Then
Echo Eval("PC." & .Item(GetNum))
Else
ArrLU = Split(.Item(GetNum), "-")
For L = ArrLU(0) To ArrLU(1)
Echo Eval("PC." & .Item(CStr(L)))
Next
End If
Else
Echo "#不支持的命令"
End If
End With
If Not Err.Number = 0 Then Echo ">X": Err.Clear
Call Main
End Sub
'DDC
Class BaseStr
Private Strs
Private Sub Class_Initialize()
Strs = ""
End Sub
Private Sub Class_Terminate()
Call Cls
End Sub
Public Sub Cls()
Strs = Empty
End Sub
Public Property Let I(ByVal Str)
If Left(Str, 1) = "☆" Then Str = Str & String(80, "=")
Strs = Strs & vbCrLf & Str
End Property
Public Default Property Get I()
I = Strs
Cls
End Property
End Class
Class BasePC
Private DPS
Private Sub Class_Initialize()
DPS = 200
End Sub
Private Sub Class_Terminate()
DPS = Empty
End Sub
Function S1()
S1 = "变量幂次方运算 " & DPS & "万次用时:" & RT("TestVar = I ^ 2", DPS * 10000)
End Function
Function S2()
S2 = "字符叠合 " & DPS & "000次用时:" & RT("TestVar = TestVar & vbTab", DPS * 1000)
End Function
Function S3()
S3 = "加法计算 " & DPS & "万次用时:" & RT("TestVar = 86 + 32", DPS * 10000)
End Function
Function S4()
S4 = "叠加计算 " & DPS & "万次用时:" & RT("TestVar = TestVar + I", DPS * 10000)
End Function
Private Function RT(ByVal MathExp, ByVal Num)
Dim NowTimer, NewTimer, TestVar
NowTimer = Timer
For I = 1 To Num
ExeCute MathExp
Next
NewTimer = FormatNumber((Timer - NowTimer) * 1000, 3, True, , False) & "ms"
RT = NewTimer
TestVar = Empty
End Function
Function BIOS()
On Error Resume Next
S.I = "☆[BIOS]"
S.I = "┏━━━━━━━━━━━━━┉"
For Each TempObj In WMI.InstancesOf("Win32_BIOS")
With TempObj
S.I = "┣厂商 :" & .Manufacturer
S.I = "┇日期 :" & .ReleaseDate
S.I = "┇OEM 版本 :" & .Version
S.I = "┇BIOS 版本 :" & .SMBIOSBIOSVersion
S.I = "┇Major版本 :" & .SMBIOSMajorVersion
S.I = "┇状态 :" & .Status
End With
Next
S.I = "┗━━━━━━━━━━━━━┉"
BIOS = S
End Function
Function OS()
On Error Resume Next
S.I = "☆[操作系统]"
S.I = "┏━━━━━━━━━━━━━┉"
For Each TempObj in WMI.InstancesOf("Win32_OperatingSystem")
With TempObj
S.I = "┣标签 :" & .Caption
S.I = "┇CSDV :" & .CSDVersion
S.I = "┇版本 :" & .Version
S.I = "┇RAM识别:" & .TotalVisibleMemorySize / 1024 & "MB"
S.I = "┇RAM可用:" & .FreePhysicalMemory / 1024 & "MB"
End With
Next
S.I = "┗━━━━━━━━━━━━━┉"
OS = S
End Function
Function Board()
On Error Resume Next
S.I = "☆[主板]"
S.I = "┏━━━━━━━━━━━━━┉"
For Each TempObj In WMI.InstancesOf("Win32_BaseBoard")
With TempObj
S.I = "┣标签:" & .Caption
S.I = "┇编号:" & .Product
S.I = "┇序号:" & .SerialNumber
S.I = "┇名称:" & .Name
S.I = "┇版本:" & .Version
S.I = "┇厂商:" & .Manufacturer
S.I = "┇状态:" & .Status
End With
Next
S.I = "┗━━━━━━━━━━━━━┉"
Board = S
End Function
Function CPU()
On Error Resume Next
S.I = "☆[CPU]"
S.I = "┏━━━━━━━━━━━━━┉"
For Each TempObj In WMI.InstancesOf("Win32_Processor")
With TempObj
MCS = .MaxClockSpeed
CCS = .CurrentClockSpeed
If MCS Mod 2 = 1 Then MCS = CCS + 1
If CCS Mod 2 = 1 Then CCS = CCS + 1
If CCS = MCS Then
Set SRP = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
SRP.GetDWORDValue &H80000002, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz |
|