vbs wmi获取电脑硬件信息实例
程序员文章站
2024-01-15 22:05:46
set wmi=getobject("winmgmts:\\") set board=wmi.instancesof("win32_baseboard"...
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,"电脑基本特征"
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,"电脑基本特征"