vbs查询局域网内电脑的软件和硬件列表清单
导读:收集整理的这篇文章主要介绍了vbs查询局域网内电脑的软件和硬件列表清单,觉得挺不错的,现在分享给大家,也给大家做个参考。 下面的代码在windows下容易报毒大家可以放心使用'=====...
收集整理的这篇文章主要介绍了vbs查询局域网内电脑的软件和硬件列表清单,觉得挺不错的,现在分享给大家,也给大家做个参考。 下面的代码在windows下容易报毒大家可以放心使用
'=========================================================================='' Date:2009/3/19' Name: 查询软件和硬件列表清单' Author:Smileruner' www.overmcse.COM' 不支持Win2000及WinNT'' 3/19,添加了网卡过滤。'=========================================================================='on error resume Nextconst 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"),0strComputer = Inputbox("请输入要查询的计算机名称",,"")If strComputer = "" then Wscript.Echo "未输入值或用户取消,查询退出。" Wscript.QuITEnd IfSet objswbeMLocator = createobject("wbemscripting.swbemlocator")Set objswbemservices = objswbemlocator.connectserver(strComputer, "root\cimv2")If Err.number >
0 then Wscript.Echo "目标计算机无法连接。错误的计算机名,或目标计算机启用了防火墙,RPC服务不可用。" Err.number.clear Wscript.QuitEnd If'swbemservices.security_.impersonationleobjvel = 3Set 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 NextEnd Function Function BoardWrite() '函数,写入主板信息 Set colBoard = objswbemservices.execquery("select * from win32_baseboard") For Each Bditem In colBoard boardname = Bditem.PRoduct WriteTable "主板",boardname NextEnd Function Function CpuWrite() '函数,写入CPU信息 Set colCpu =objswbemservices.execquery("select * from win32_processor") For Each item in colCpu cpuname = (trim(item.name)) WriteTable "中央处理器",cpuname NextEnd Function Function MemoryWrite() '函数,写入内存信息mtotal = 0num = 0mill = 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" NextEnd 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 NextEnd FunctionFunction videoWrite() '函数,写入显示卡信息 Set colVideo = objswbemservices.execquery("select * from win32_videocontroller", , 48) For Each objitem in colVideo videoname = (trim(objitem.caption) &
(objitem.videomodedescription)) WriteTable "显示卡",videoname NextEnd 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 NextEnd 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 IfNext End FunctionFunction NotHotfix(sSubKey) If Left(sSubkey,2) = "KB" And len(sSubkey) = 8 Then NotHotfix = 0 Else NotHotfix = 1 End ifEnd FunctionFunction getProgNameAndVersion(oReg,sKeyRoot)Dim sKeyValuesAry, iKeyTypesAry, nCnt, sValue, sDisplayName, sDisplayVersionoReg.EnumValues HKEY_LOCAL_MACHINE, sKeyRoot, sKeyValuesAry, iKeyTypesAry If NOT IsArray(sKeyValuesAry) Then getProgNameAndVersion = 0 Exit Function End If For nCnt = 0 To UBound(sKeyValuesAry) If InStr(1, sKeyValuesAry(nCnt), "DisplayName", vbTextCompare) Then If iKeyTypesAry(nCnt) = REG_SZ Then oReg.GetStringValue HKEY_LOCAL_MACHINE, sKeyRoot, sKeyValuesAry(nCnt), sValue If sValue>
"" Then sDisplayName = sValue sDisplayName = Replace(sDisplayName, "[", "(") sDisplayName = Replace(sDisplayName, "]", ")") End If End If Elseif InStr(1, sKeyValuesAry(nCnt), "DisplayVersion", vBTextCompare) Then If iKeyTypesAry(nCnt) = REG_SZ Then oReg.GetStringValue HKEY_LOCAL_MACHINE, sKeyRoot, sKeyValuesAry(nCnt), sValue If sValue>
"" Then sDisplayVersion = sValue End If End If If (sDisplayName>
"") AND (sDisplayVersion>
"") Then getProgNameAndVersion = sDisplayName &
" --版本号: " &
sDisplayVersion Exit Function Else getProgNameAndVersion = 0 End If Next If sDisplayName>
"" Then getProgNameAndVersion = sDisplayName Exit Function End IfEnd FunctionFunction WriteTable(caption,value) '函数,将数据写入HTML单元格resultFile.Writeline "tr>
"resultFile.Writeline "td align=""left"" width=""30%"" height=""25"" bgcolor=""#ffffff"" scope=""row"">
&
nbsp;
&
nbsp;
" &
caption &
"/td>
"resultFile.Writeline "td bgcolor=""#ffffff"">
&
nbsp;
&
nbsp;
" &
value &
"/td>
"resultFile.Writeline "/tr>
"End Function Function HtmlWriteHead() '函数,写入THML文件头resultFile.Writeline "html>
" resultFile.Writeline "head>
" resultFile.Writeline "title>
软硬件配置清单/title>
"resultFile.Writeline "/head>
" resultFile.Writeline "body>
" End Function Function HtmlWriteEnd() '函数,写入Html文件尾resultFile.Writeline "/body>
" resultFile.Writeline "/html>
" End Function Function TableHead(pcname,str) '函数,写入Html表格结尾resultFile.Writeline "h3>
" &
pcname &
str &
" -- date:"&
now()&
" /h3>
" &
VbCrLfresultFile.Writeline "table width=""90%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""1"" bgcolor=""#0000ff"">
" resultFile.Writeline "tr>
" resultFile.Writeline "th width=""30%"" height=""25"" bgcolor=""#ffffff"" scope=""col"">
资产类型/th>
"resultFile.Writeline "th bgcolor=""#ffffff"" scope=""col"">
查询结果值/th>
"resultFile.Writeline "/tr>
" strstyle = "th width=""30%"" height=""25"" bgcolor=""#ffffff"" scope=""row"">
"End Function Function TableEnd() '函数,Html表格结尾resultFile.Writeline "/table>
" End Function vbs判断操作系统
strComputer = "."Set objWMIService = GetObject("winmgmts:\\" &
strComputer &
"\root\cimv2")Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")For Each objItem in colItemsstrOSVersion = objItem.VersionNextwscript.echo strOSversionselect case strOSversioncase "5.2.3790"wscript.echo "Windows Server 2003"case "5.0.2195"wscript.echo "Windows 2000"case "5.1.2600"wscript.echo "Windows xp"case "6.0.6001"wscript.echo "windows visita"Case "6.1.7601"wscript.echo "Windows Server 2008 r2"case elsewscript.echo "i don't know"end select到此这篇关于vbs查询局域网内电脑的软件和硬件列表清单的文章就介绍到这了,更多相关查询软件和硬件列表清单内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: vbs查询局域网内电脑的软件和硬件列表清单
本文地址: https://pptw.com/jishu/610191.html
