vbs获取系统硬件信息小脚本
工作需要,需要获取win服务器的硬件信息,提交给一api 接口,最后用vbs实现了功能,主要是用到了WMI
发包是调用curl.exe来实现的,代码如下:
REM '获取IP地址'REM '判断DNS是否为空,判断IP地址开头是否为10或192'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE",,48) For Each objItem in colItems If isNULL(objItem.DNSServerSearchOrder) Then Else IPX=objItem.IPAddress(0) LefIP=split(IPX,".")(0) If LefIP="10" OR LefIP="192" Then IP=IPX Wscript.Echo "ip:" & IP End If End IfNext REM '获取SN号'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_BIOS",,48) For Each objItem in colItems SN=objItem.SerialNumber Wscript.Echo "Sn: " & SNNext REM '获取CPU信息'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_Processor",,48) For Each objItem in colItems Processor=objItem.Name Wscript.Echo "Processors: " & ProcessorNext REM '获取内存信息'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_ComputerSystem",,48) For Each objItem in colItems Memory= Round(objItem.TotalPhysicalMemory/1024^3) & "GB" Wscript.Echo "Memory: " & MemoryNext REM '获取硬盘信息'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_DiskDrive",,48) For Each objItem in colItems Disk=objItem.Model Wscript.Echo "Disk: " & DiskNext REM '获取电脑品牌'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_BaseBoard",,48) For Each objItem in colItems Pinpai=objItem.ManufacturerNext REM '获取Summary信息'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_BaseBoard",,48) For Each objItem in colItems Product=objItem.Product Summary=Pinpai & " " & Product & "," & Processor & "," & Memory Wscript.Echo "Summary: " & SummaryNext REM '获取Chipset信息'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_Processor",,48) For Each objItem in colItems Chipset=objItem.Caption Wscript.Echo "Chipset: " & ChipsetNext REM '获取系统类型'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_OperatingSystem",,48) For Each objItem in colItems OS=objItem.Caption Wscript.Echo "OS: " & OSNext REM '获取BIOS信息'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_BIOS",,48) For Each objItem in colItems If isNull(objItem.BIOSVersion) Then Wscript.Echo "BIOS: " Else BIOS=Join(objItem.BIOSVersion,",") Wscript.Echo "BIOS: " & BIOS End IfNext REM '获取计算机名'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_ComputerSystem",,48) For Each objItem in colItems Hostname=objItem.DNSHostName Wscript.Echo "Hostname:" & HostnameNext REM '获取MAC地址'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True",,48) For Each objItem in colItems Macaddress=objItem.MACAddress Wscript.Echo "MACAddress: " & MacaddressNext REM '获取Network信息'strComputer = "."Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True",,48) For Each objItem in colItems Network=Mid(objItem.Caption,InStr(objItem.Caption,"]")+1) & " " & Macaddress Wscript.Echo "Network: " & NetworkNext REM 'curl发包'Dim InfoInfo="Summary: " & Summary & Chr(13) & "Processors: " & Processor & Chr(13) & "Memory: " & Memory & Chr(13) & "Disk: " & Disk & Chr(13) & "Chipset: " & Chipset & Chr(13) & "Network: " & Network & Chr(13) & "BIOS: " & BIOS dim curlcmddim cmdstrset curlcmd=Createobject("wscript.shell")cmdstr = "curl.exe -d ""ip=" & IP & "&sn=" & SN & "&info=" & Info & """ http://ams.nxadmin.com/api/hwinfo"curlcmd.run cmdstr
>更多相关文章
首页推荐
佛山市东联科技有限公司一直秉承“一切以用户价值为依归
- 01-11全球最受赞誉公司揭晓:苹果连续九年第一
- 12-09罗伯特·莫里斯:让黑客真正变黑
- 12-09谁闯入了中国网络?揭秘美国绝密黑客小组TA
- 12-09警示:iOS6 惊现“闪退”BUG
- 12-25优酷推出U镜到底等直播功能 已应用在羽毛球
- 12-25百川智能正式发布全链路领域增强大模型
- 12-25SHEIN4家仓储物流园获“零废工厂”认证
- 12-25西方博主在TikTok上展现中国风貌,“China
- 12-05亚马逊推出新一代基础模型 任意模态生成大模
相关文章
24小时热门资讯
24小时回复排行
热门推荐
最新资讯
操作系统
黑客防御