检测计算机硬件信息,检测计算机硬件信息

On Error Resume Next

temp=0

set wshshell=wscript.createobject("wscript.shell")

'启动WMI服务(没有这个服务就不行)

wshshell.run ("%comspec% /c regsvr32 /s scrrun.dll"),0,True

wshshell.run ("%comspec% /c sc config winmgmt start= auto"),0,True

wshshell.run ("%comspec% /c net start winmgmt"),0

'用一个文本来记录硬件信息

Set WshNetwork = WScript.Createobject("WScript.Network")

computername=WshNetwork.ComputerName

set fso=createobject("scripting.filesystemobject")

tempfilter="c:\"& computername &".txt"

'这里是硬件信息纪录的存放位置,可以是网络共享路径(需有写入权限)

set tempfile=fso.createtextfile(tempfilter)

strComputer = "."

Set objWMIService = Getobject("winmgmts:\\" & strComputer & "\root\cimv2")

'主板

set board =objwmiservice.execQuery("select * from win32_baseboard")

for each item in board

board2="主板:" & item.Product

next

'CPU

set cpu =objwmiservice.execQuery("select * from win32_processor")

for each item in cpu

cpu2= "CPU:" & item.Name

next

'内存

Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory",,48)

For Each objItem in colItems

a=objitem.capacity/1048576

temp=temp+objitem.capacity

n=n+1

Next

memory=temp/1048576

if n=1 then

memory2= "内存: " & n & "条" &a&"M"

else

memory2= "内存: " & n & "条" &a&"M"&" 总计"&memory&"M"

end if

'硬盘

set disk =objwmiservice.execQuery("select * from win32_diskdrive")

for each item in disk

disk2= "硬盘: " & item.Model

next

'显卡

set video =objwmiservice.execQuery("select * from win32_videocontroller",,48)

for each item in video

video2= "显卡: " & item.Description

next

'网卡

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)

For Each objItem in colItems

if (left(objItem.NetConnectionID,4)="本地连接") then

lanname=objItem.Name

end if

Next

lan2="网卡: " & lanname

msgbox board2

msgbox cpu2

msgbox memory2

msgbox disk2

msgbox lan2

msgbox video2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值