查询软件和硬件列表清单[将文章里代码另存为 list.vbs,双击运行就会出现一个html页面]
'==========================================================================
' Name: 查询软件和硬件列表清单
' 不支持Win2000及WinNT'
'==========================================================================
'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
strIPPattern = "((2[0-4]\d|25[0-5]|1?\d\d?)\.){3}(2[0-4]\d|25[0-5]|1?\d\d?)"
Set objNet = createobject("Wscript.Network")
Set objRegExp = New RegExp
objregexp.Pattern = strIPPattern
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
If InStr(IPConfig.Caption(i),"VMware") = 0 And InStr(IPConfig.Caption(i),"Microsoft") = 0 Then
If InStr(IPConfig.Caption(i),"169.254") = 0 And InStr(IPConfig.Caption(i),"0.0.0.0") = 0 Then
If objregexp.Test(IPConfig.IPAddress(i)) = True Then
strIP = IPConfig.IPAddress(i)
End If
End If
End If
Next
End If
Next
strUser = objnet.UserName
Set objNetwork = CreateObject("WScript.Network")
'==========================================================================
strComputer = objNetwork.ComputerName
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 Left(sSubkey,2) = "KB" And len(sSubkey) = 8 Then
NotHotfix = 0
Else NotHotfix = 1
End if
End Function
Function getProgNameAndVersion(oReg,sKeyRoot)
Dim sKeyValuesAry, iKeyTypesAry, nCnt, sValue, sDisplayName, sDisplayVersion
oReg.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 If
End Function
Function WriteTable(caption,value)
'函數,將数据写入HTML單元格
resultFile.Writeline "<tr>"
resultFile.Writeline "<td align=""left"" width=""30%"" height=""25"" bgcolor=""#ffffff"" scope=""row""> " & caption & "</td>"
resultFile.Writeline "<td bgcolor=""#ffffff""> " & 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>" & VbCrLf
resultFile.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
查询软件和硬件列表清单[将文章里代码另存为 list.vbs,双击运行就会出现一个html页面]的更多相关文章
- Delphi 基本数据类型列表 高级数据类型列表 字符类型查询列表清单
原文:Delphi 基本数据类型列表 高级数据类型列表 字符类型查询列表清单 长长的列表文字类型文件 分类 范围 字节 备注 简单类型 序数 整数 Integer -2147483648 .. 214 ...
- Java 框架、库和软件的精选列表(awesome java)
原创翻译,原始链接 本文为awesome系列中的awesome java Awesome Java Java 框架.库和软件的精选列表 项目 Bean映射 简化 bean 映射的框架 dOOv - 为 ...
- Flask开发天气查询软件,带你掌握pipenv的使用与手机Termux下的部署
关于pipenv 昨天介绍了pipenv这个相比于virtualenv更高端大气上档次的虚拟环境管理软件,但看了下流量貌似不是很受欢迎,也许是我介绍的不够好吧.那么今天就拿它做一个例子,开发一款天气预 ...
- ubuntu 12.10 sourcelist软件更新源列表(zz)
ubuntu 12.10正式版已经发布了,国内各大开源软件源也陆续更新了资源.今天分享一下ubuntu 12.10 软件更新源列表. 首先,备份一下ubuntu 12.04 原来的源地址列表文 ...
- dedecms列表页如何让文章列表里面的文章每隔五篇就隔开一段空间
dedecms列表页如何让文章列表里面的文章每隔五篇就隔开一段空间,运用js控制列表样式的方法. 代码如下: <script type="text/javascript"&g ...
- 织梦CMS(dedecms)栏目属性及系统封面模板、列表模板、文章模板区别和路径设置解答
问题一:(织梦"栏目管理"的"常规选项"中3个栏目属性分析?) 织梦CMS的栏目属性分成三种, -->最终列表栏目 -->频道封面 -->外部 ...
- 热爱工作 发财机会大增(这里不是选择软件还是硬件的问题,是自己的性格和追求的问题)——当你的老板不如你懂行的时候,还赚的盆满钵满的时候,你就可以考虑独立了 good
爱工作 发财机会大增 [ 油老板 ] 于:2011-02-09 06:39:41 复:1269077 认真回顾发主贴以来的三年半,俺觉得对于想发财的上班族来说,认真工作,刻苦钻研是发财的重要保证. 为 ...
- ubuntu 12.10 软件更新源列表
ubuntu 12.10正式版已经发布了,国内各大开源软件源也陆续更新了资源.今天分享一下ubuntu 12.10 软件更新源列表. 首先,习惯性的备份一下ubuntu 12.04 原来的源地址列表文 ...
- dede list列表页和文章页分别使用if else
标签: dede 2015-01-25 19:33 755人阅读 评论(0) 收藏 举报 分类: [ Dede ](20) 版权声明:本文为博主原创文章,未经博主允许不得转载. list列表页中使用i ...
随机推荐
- .NetCore简介
引用:https://docs.microsoft.com/zh-cn/dotnet/articles/core/index .NET Core 是一个通用开发平台,由 Microsoft 和 Git ...
- 【C++程序员学 python】python 之变量
既然学过C++,那么就应该知道变量是什么,常量是什么. python 相比于C++,在使用变量之前不用先声明. 而是直接使用,python 会根据你的变量自动识别其类型. 假如a = 123 那么a ...
- c#写一个网站后台扫描器
主要分成了那么几个步骤: 1.HTTP状态码 2.字典的导入 3.显示在listview控件当中 第一步: 先来实现HTTP状态码200的判断 try { req = (HttpWebRequest) ...
- R-tree 一种空间搜索的动态索引结构
译林:R-tree 一种空间搜索的动态索引结构Antonm Guttman 摘要为了有效地处理空间数据,正如在计算机辅助设计和地理数据应用中所要求的那样,数据库需要一种索引机制能根据它们的空间位置快速 ...
- LAN8710A/LAN8710Ai datasheet 记录
因为产品的双网口出现了问题,而且是AM335x 内部驱动,难度比较大,现从PHY 端开始分析相关原理,找到双网口不能使用的原因. 此篇是记录一些有关LAN8710A 这个PHY的一些特性. 各个功能模 ...
- 树莓派Raspberry命令行配置无线网络连接
前言: 树莓派有多种联网的方式,通过有线网或者通过无线网.通过有线网连接是比较简单的,在开启dhcp的路由器下,直接插上网线就可以联网,本文介绍树莓派无线联网的方式.再没联网的情况下,如果没有屏幕等外 ...
- node-webkit连接mysql
一.安装node.js mysql驱动库 node-webkit里面没有mysql模块的,我们需要安装mysql模块.我们可以使用npm(Node package manager)进行安装.这里使用到 ...
- 21个最佳jQuery插件推荐
在Javascript应用领域上,使用jQuery可以制作出非常优秀的动画效果,滑块.滑球,以及各种不同的应用.精选出21个最佳的精典案例,如果你是一个前端设计师,一定不要错过. Supersized ...
- C的内存四大区
前提 看视频得来的内容,只知道不止4个区,但主要是这4个区. 四区 静态区 用于存放所有的全局变量和静态变量. ; //静态区 int main(){ ; //静态区 ; } 代码区 就是存放程序的执 ...
- RequireJS使用小结1——for Effective JavaScript Module Loading
1. require和define的区别 The require() function is used to run immediate functionalities, while define() ...