网上抄的,改了改,会弹出2个CMD窗口,一个是IPconfig 显示IP 另外一个需要手动输入姓名,部门,IP。(输入姓名部门和IP作为文件的名称)可以关闭全部回显直接生成,生成的文件保存在C盘根目录。

复制下面代码直接保存到txt里面,然后再修改txt文本后缀为.bat即可

' 2>nul 3>nul&cls&@echo off
'&rem 获取本机系统及硬件配置信息
'&title 硬件配置信息
'&color 0a
'&start cmd /k ipconfig
'&cd /d "%~dp0"
'&echo 姓名:%name%
'&set /p name=
'&echo 部门:%department%
'&set /p department=
'&echo IP:%ip%
'&set /p ip=
'&TIME /T
'&set "outfile=C:\%ip%%department%%name%.txt"
'&cscript -nologo -e:vbscript "%~fs0"
'&cscript -nologo -e:vbscript "%~fs0">"%outfile%"
'&echo;
'&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
最后修改:2023 年 04 月 17 日
如果觉得我的文章对你有用,请随意赞赏