Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12898
  • 博文数量: 19
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 270
  • 用 户 组: 普通用户
  • 注册时间: 2013-03-11 10:10
文章分类
文章存档

2015年(3)

2014年(8)

2013年(8)

我的朋友
最近访客

分类: IT职场

2014-10-06 10:29:35


本脚本的功用是检测硬件的信息。
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="\\192.168.0.201\11\"& computername &".txt"
'\\game\ps$\是供职器寄存配件表的位置。同享要完整享
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
tempfile.writeline(board2)
tempfile.writeline(cpu2)
tempfile.writeline(memory2)
tempfile.writeline(disk2)
tempfile.writeline(video2)
tempfile.writeline(lan2)

//正在启动里即可以统计硬件

阅读(486) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~