vbs查询局域网内电脑的软件和硬件列表清单

这个是可以帮助大家轻松获取局域网内电脑的相关软硬件新的的一个小工具,希望能帮助到大家,需要的朋友可以参考下

下面的代码在windows下容易报毒大家可以放心使用

 '========================================================================== ' ' Date:2009/3/19 ' Name: 查询软件和硬件列表清单 ' Author:Smileruner ' www.overmcse.com ' 不支持Win2000及WinNT ' ' 3/19,添加了网卡过滤。 '========================================================================== 'on error resume Next const HKEY_LOCAL_MACHINE = &H80000002 const UNINSTALL_ROOT = "Software\Microsoft\Windows\CurrentVersion\Uninstall" const REG_SZ = 1 'Set wshshell=wscript.createobject("wscript.shell") ' 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 strComputer = Inputbox("请输入要查询的计算机名称",,"") If strComputer = "" then Wscript.Echo "未输入值或用户取消,查询退出。" Wscript.Quit End If Set objswbemlocator = createobject("wbemscripting.swbemlocator") Set objswbemservices = objswbemlocator.connectserver(strComputer, "root\cimv2") If Err.number <> 0 then Wscript.Echo "目标计算机无法连接。错误的计算机名,或目标计算机启用了防火墙,RPC服务不可用。" Err.number.clear Wscript.Quit End If 'swbemservices.security_.impersonationleobjvel = 3 Set fso=createobject("scripting.filesystemobject") FileDate = Replace(date(), "/", "-") resoultfilepath= strComputer & FileDate & ".html" Set resultFile= fso.createtextfile(resoultfilepath,,true) HtmlWriteHead() 'Html文档开始 TableHead strComputer,"硬件清单" 'Html表格开始 OsWrite() '写入操作系统信息 BoardWrite() '写入主板信息 CpuWrite() '写入CPU信息 MemoryWrite() '写入内存信息 HarddiskWrite() '写入硬盘信息 CdromWrite() '写入CDROM信息 VideoWrite() '写入显示卡信息 NetcardWrite() '写入网卡信息 TableEnd() 'Html表格结尾 TableHead strComputer,"软件清单" 'Html表格开头 Softlist() '写入软件信息 TableEnd() 'Html表格结尾 HtmlWriteEnd() 'Html文档结束 ResultFile.close Wscript.Echo "查询完成!" '=========以下是函数列表========== Function OsWrite() '函数,写入操作系统信息 Set colOs =objswbemservices.execquery("select * from win32_operatingsystem",,48) For Each Ositem In colOs oscaption = Ositem.caption OsVersion = oscaption & Ositem.version WriteTable "操作系统",OsVersion Next End Function Function BoardWrite() '函数,写入主板信息 Set colBoard = objswbemservices.execquery("select * from win32_baseboard") For Each Bditem In colBoard boardname = Bditem.product WriteTable "主板",boardname Next End Function Function CpuWrite() '函数,写入CPU信息 Set colCpu =objswbemservices.execquery("select * from win32_processor") For Each item in colCpu cpuname = (trim(item.name)) WriteTable "中央处理器",cpuname Next End Function Function MemoryWrite() '函数,写入内存信息 mtotal    = 0 num     = 0 mill     = 0 Set colMemory = objswbemservices.execquery("select * from win32_physicalmemory",,48) For Each objitem In colMemory mill = objitem.capacity/1048576 WriteTable "单根内存容量",mill & "M" mtotal = mtotal+mill num = num + 1 Next WriteTable "总计内存",num & "条" & "一共" & mtotal & "M" End Function Function HarddiskWrite() '函数,写入硬盘信息 Set colDisk = objswbemservices.execquery("select * from win32_diskdrive", , 48) For Each objitem In colDisk diskname= objitem.caption disksize= fix(objitem.size/1073741824) WriteTable "硬盘",diskname & " 容量:" & disksize & "G" Next End Function Function CdromWrite() '函数,写入CDROM信息 Set colCdrom = objswbemservices.execquery("select * from win32_cdromdrive where scsitargetid=0") For Each objitem In colCdrom cdname = objitem.name WriteTable "光驱",cdname Next End Function Function videoWrite() '函数,写入显示卡信息 Set colVideo = objswbemservices.execquery("select * from win32_videocontroller", , 48) For Each objitem in colVideo videoname = (trim(objitem.caption) & (objitem.videomodedescription)) WriteTable "显示卡",videoname Next End Function Function netcardWrite() '函数,查询网卡信息 Set colNetcards = objswbemservices.execquery("select * from win32_networkadapter") For Each objNetcard in colNetcards If Not IsNull(objNetcard.NetConnectionID) Then NetCardName     = objNetcard.productname WriteTable "网卡名称",NetCardName If objNetcard.NetConnectionStatus = 2 Then NetCardMac     = objNetcard.macaddress WriteTable "网卡Mac",NetCardMac strQueryIp ="select * from win32_networkadapterconfiguration" &_ " where IPEnabled = true" &_ " and macaddress = '" & objNetcard.macaddress & "'" Set colNetcardCfgs = objswbemservices.execquery(strQueryIp) For Each objNetcardCfg in colNetcardCfgs For Each CfgAdrress in objNetcardCfg.IPAddress IpAdrress = CfgAdrress WriteTable "IP地址",IpAdrress Next Next Else NetCardMac = "网卡被禁用或未连接。" WriteTable "网卡Mac",NetCardMac IpAdrress = "网卡被禁用或未连接。" WriteTable "IP地址",IpAdrress End If End if Next End Function Function softlist() '函数,写入软件信息 Set StdOut = WScript.StdOut Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") strKeyPath = UNINSTALL_ROOT oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys For Each strSubKey In arrSubKeys If NotHotfix(strSubKey) Then SoftNameAndVersion = getProgNameAndVersion(oReg,strKeyPath & "\" & strSubKey) If SoftNameAndVersion<>"0" Then WriteTable "软件",SoftNameAndVersion End If End If Next End Function Function NotHotfix(sSubKey) If

以上就是vbs查询局域网内电脑的软件和硬件列表清单的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 脚本专栏