以下内容另存为xx.vbs即可:
' 获取计算机名称
Set objNetwork = CreateObject("WScript.Network")
computerName = objNetwork.ComputerName
' 获取操作系统版本
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objItem In colItems
osVersion = objItem.Caption & " " & objItem.Version
Next
' 获取计算机品牌型号
Set colComputerSystem = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputerSystem In colComputerSystem
computerBrandModel = objComputerSystem.Manufacturer & " " & objComputerSystem.Model
Next
' 获取磁盘型号
Set colDisks = objWMIService.ExecQuery("Select * from Win32_DiskDrive")
diskModels = ""
For Each objDisk In colDisks
diskModels = diskModels & objDisk.Model & vbCrLf
Next
' 获取 CPU 型号
Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor")
cpuModel = ""
For Each objProcessor In colProcessors
cpuModel = cpuModel & objProcessor.Name & vbCrLf
Next
' 获取内存大小
Set colMemory = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")
totalMemory = 0
For Each objMemory In colMemory
totalMemory = totalMemory + CDbl(objMemory.Capacity) ' 使用 CDbl 避免溢出
Next
totalMemoryGB = Round(totalMemory / 1024 / 1024 / 1024, 2) & " GB"
' 获取当前日期和时间
currentDateTime = Now
' 拼接所有信息
result = "计算机品牌型号: "& vbCrLf & computerBrandModel & vbCrLf & _
"计算机名称: "& vbCrLf & computerName & vbCrLf & _
"操作系统版本: "& vbCrLf & osVersion & vbCrLf & _
"CPU 型号: " & vbCrLf & cpuModel & _
"内存大小: " & vbCrLf & totalMemoryGB & vbCrLf & _
"磁盘型号: " & vbCrLf & diskModels & vbCrLf & _
"当前日期时间: " & currentDateTime & vbCrLf & _
"Powered by:苏州凡卓文化科技有限公司 李源13390869205"
' 使用 MsgBox 显示结果
MsgBox result, vbInformation, "系统信息"