vbs wmi获取电脑硬件信息实例

所属分类: 脚本专栏 / vbs 阅读数: 2019
收藏 0 赞 0 分享
Set wmi=GetObject("winmgmts:\\")

Set board=wmi.instancesof("win32_baseboard")
For Each b In board
msg="主板:"&b.Manufacturer&vbTab&b.product&vbTab&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)

Set cpus=wmi.instancesof("win32_processor")
msg=msg&"CPU 特征:"+Chr(13)
For Each cpu In cpus
msg=msg+cpu.deviceid&vbTab&cpu.name&Chr(13) _
&vbtab&cpu.SocketDesignation&vbtab&cpu.CurrentClockSpeed&"MHz"&vbtab&cpu.l2cachesize&"Kb_L2"&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)

Set mem=wmi.instancesof("win32_physicalmemory")
msg=msg&"内存容量:"+Chr(13)
For Each    m In mem
msg=msg&m.tag&space(10)&m.capacity&+Chr(13)
Next

Set mem=wmi.instancesof("win32_computersystem")
For Each m In mem
msg=msg&"内存总容量:"&Round((m.totalphysicalmemory/1024^2),2)&"M"+Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)

Set display=wmi.instancesof("Win32_videocontroller")
msg=msg&"显示系统:"+Chr(13)
For Each     video In display
msg=msg&video.deviceid&vbTab&video.name&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)


Set disks=wmi.instancesof("win32_diskdrive")
msg=msg&"硬盘容量:"+Chr(13)
For Each d In disks
If int(d.size/(1024^3))=0 Then 
n=Round(d.size/(1024^2),2)&"M"
Else
n=Round(d.size/(1024^3),2)&"G"
End If

msg=msg+d.deviceid&"      空间为: "&n&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)


MsgBox msg,0,"电脑基本特征"

更多精彩内容其他人还在看

VBS教程:函数-Asc 函数

VBS教程:函数-Asc 函数
收藏 0 赞 0 分享

VBS教程:函数-Array 函数

VBS教程:函数-Array 函数
收藏 0 赞 0 分享

VBS教程:函数-Abs 函数

VBS教程:函数-Abs 函数
收藏 0 赞 0 分享

VBS教程:在 VBScript 中使用对象

VBS教程:在 VBScript 中使用对象
收藏 0 赞 0 分享

VBS教程:VBScript 与窗体

VBS教程:VBScript 与窗体
收藏 0 赞 0 分享

VBS教程:VBScript 页面的简单样例

VBS教程:VBScript 页面的简单样例
收藏 0 赞 0 分享

VBS教程:VBScript 基础-VBScript编码约定

VBS教程:VBScript 基础-VBScript编码约定
收藏 0 赞 0 分享

VBS教程:VBScript 基础-VBScript 过程

VBS教程:VBScript 基础-VBScript 过程
收藏 0 赞 0 分享

VBS教程:函数-TypeName 函数

VBS教程:函数-TypeName 函数
收藏 0 赞 0 分享

VBS教程:函数-TimeValue

VBS教程:函数-TimeValue
收藏 0 赞 0 分享
查看更多