如何将通过bat批处理命令获取到的电脑信息,保存到本地或服务器

wx6341357546245
发布于 2022-10-14 17:45
浏览
0收藏

脚本如下,但是只是获取到了电脑硬件信息,不能保存到本地或服务器:

’ 2>nul 3>nul&cls&@echo off
'&rem 获取本机系统及硬件配置信息
'&set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
'&title %#% +%$%%$%/%@% %z%
'&cd /d “%~dp0”
'&set “outfile=xxx.txt”
'&cscript -nologo -e:vbscript “%~fs0”
'&echo;%#% +%$%%$%/%@% %z%
'&pause&exit

On Error Resume Next
Set fso=CreateObject(“Scripting.Filesystemobject”)
Set ws=CreateObject(“WScript.Shell”)
Set wmi=GetObject(“winmgmts:\.\root\cimv2”)

WSH.echo “---------------系统-------------”
Set query=wmi.ExecQuery(“Select * from Win32_ComputerSystem”)
For each item in query
WSH.echo “当前用户=” & item.UserName
WSH.echo “工作组=” & item.Workgroup
WSH.echo “域=” & item.Domain
WSH.echo “计算机名=” & item.Name
WSH.echo “系统类型=” & item.SystemType
Next

Set query=wmi.ExecQuery(“Select * from Win32_OperatingSystem”)
For each item in query
WSH.echo “系统=” & item.Caption & “[” & item.Version & “]”
WSH.echo “初始安装日期=” & item.InstallDate
visiblemem=item.TotalVisibleMemorySize
virtualmem=item.TotalVirtualMemorySize
Next

Set query=wmi.ExecQuery(“Select * from Win32_ComputerSystemProduct”)
For each item in query
WSH.echo “制造商=” & item.Vendor
WSH.echo “型号=” & item.Name
Next

WSH.echo “---------------主板BIOS-------------”
Set query=wmi.ExecQuery(“Select * from Win32_BaseBoard”)
For each item in query
WSH.echo “制造商=” & item.Manufacturer
WSH.echo “序列号=” & item.SerialNumber
Next

Set query=wmi.ExecQuery(“Select * from Win32_BIOS”)
For each item in query
WSH.echo “名称=” & item.Name
WSH.echo “bios制造商=” & item.Manufacturer
WSH.echo “发布日期=” & item.ReleaseDate
WSH.echo “版本=” & item.SMBIOSBIOSVersion
Next

WSH.echo “---------------CPU-------------”
Set query=wmi.ExecQuery(“Select * from WIN32_PROCESSOR”)
For each item in query
WSH.echo “序号=” & item.DeviceID
WSH.echo “名称=” & item.Name
WSH.echo “核心=” & item.NumberOfCores
WSH.echo “线程=” & item.NumberOfLogicalProcessors
Next

WSH.echo “---------------内存-------------”
WSH.echo “总物理内存=” & FormatNumber(visiblemem/1048576,2,True) & " GB"
WSH.echo “总虚拟内存=” & FormatNumber(virtualmem/1048576,2,True) & " GB"
Set query=wmi.ExecQuery(“Select * from Win32_PhysicalMemory”)
For each item in query
WSH.echo “序号=” & item.Tag
WSH.echo “容量=” & FormatSize(item.Capacity)
WSH.echo “主频=” & item.Speed
WSH.echo “制造商=” & item.Manufacturer
Next

WSH.echo “--------------硬盘-------------”
Set query=wmi.ExecQuery(“Select * from Win32_DiskDrive”)
For each item in query
WSH.echo “名称=” & item.Caption
WSH.echo “接口=” & item.InterfaceType
WSH.echo “容量=” & FormatSize(item.Size)
WSH.echo “分区数=” & item.Partitions
Next

Set query=wmi.ExecQuery(“Select * from Win32_LogicalDisk Where DriveType=3 or DriveType=2”)
For each item in query
WSH.echo item.Caption & Chr(9) & item.FileSystem & Chr(9) & FormatSize(item.Size) & Chr(9) & FormatSize(item.FreeSpace)
Next

WSH.echo “--------------网卡-------------”
Set query=wmi.ExecQuery(“Select * from Win32_NetworkAdapter Where NetConnectionID !=null and not Name like ‘%Virtual%’”)
For each item in query
WSH.echo “名称=” & item.Name
WSH.echo “连接名=” & item.NetConnectionID
WSH.echo “MAC=” & item.MACAddress
Set query2=wmi.ExecQuery(“Select * from Win32_NetworkAdapterConfiguration Where Index=” & item.Index)
For each item2 in query2
If typeName(item2.IPAddress) <> “Null” Then
WSH.echo “IP=” & item2.IPAddress(0)
End If
Next
Next

WSH.echo “--------------显示-------------”
Set query=wmi.ExecQuery(“Select * from Win32_VideoController”)
For each item in query
WSH.echo “名称=” & item.Name
WSH.echo “显存=” & FormatSize(Abs(item.AdapterRAM))
WSH.echo “当前刷新率=” & item.CurrentRefreshRate
WSH.echo “水平分辨率=” & item.CurrentHorizontalResolution
WSH.echo “垂直分辨率=” & item.CurrentVerticalResolution
Next

WSH.echo “--------------声卡-------------”
Set query=wmi.ExecQuery(“Select * from WIN32_SoundDevice”)
For each item in query
WSH.echo item.Name
Next

WSH.echo “--------------打印机-------------”
Set query=wmi.ExecQuery(“Select * from Win32_Printer”)
For each item in query
If item.Default =True Then
WSH.echo item.Name & “(默认)”
Else
WSH.echo item.Name
End If
Next

Function FormatSize(byVal t)
If t >= 1099511627776 Then
FormatSize = FormatNumber(t/1099511627776, 2, true) & " TB"
ElseIf t >= 1073741824 Then
FormatSize = FormatNumber(t/1073741824, 2, true) & " GB"
ElseIf t >= 1048576 Then
FormatSize = FormatNumber(t/1048576, 2, true) & " MB"
ElseIf t >= 1024 Then
FormatSize = FormatNumber(t/1024, 2, true) & " KB"
Else
FormatSize = t & " B"
End If
End Function

收藏
回复
举报
回复
添加资源
添加资源将有机会获得更多曝光,你也可以直接关联已上传资源 去关联
    相关推荐