自动化运维-收集电脑软硬件信息

自动化收集公司内所有电脑的软件和硬件信息 作者:蓝眼泪 需求背景简介: 公司内有1000多台电脑,如果靠人工收集,非常耗费时间,为此本人花了1个月时间,用vbs代码实现收集信息功能。结合域控组策略,实现自动化收集软件和硬件信息。代码如下

自动化收集公司内所有电脑的软件和硬件信息

作者:蓝眼泪

需求背景简介:
公司内有1000多台电脑,如果靠人工收集,非常耗费时间,为此本人花了1个月时间,用vbs代码实现收集信息功能。结合域控组策略,实现自动化收集软件和硬件信息。代码如下:

const HKEY_LOCAL_MACHINE = &H80000002 
const UNINSTALL_ROOT = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
const REG_SZ = 1

'strUsername="administrator" 
'strPassword="8888" 

'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
strUsername = Inputbox("计算机管理员账号",,"")

If strUsername = "" then
        Wscript.Echo "未输入值或用户取消,查询退出。"
        Wscript.Quit
End If
strPassword = Inputbox("计算机管理员密码",,"")

If strPassword = "" then
        Wscript.Echo "未输入值或用户取消,查询退出。"
        Wscript.Quit
End If

Set objswbemlocator = createobject("wbemscripting.swbemlocator")
Set objswbemservices = objswbemlocator.connectserver(strComputer, "root\cimv2", strUsername ,strPassword)
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()
              

发布者:admin,转转请注明出处:http://www.yc00.com/web/1755052463a5233618.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信