这个功能共需要两个文件(要在同一目录下)

创建并保存以下两个文件
文件一 hardware_info.bat
@echo off
setlocal enabledelayedexpansion
:: 运行 PowerShell 脚本
powershell -File "%~dp0hardware_info.ps1"
:: 清理临时文件
@REM del "%~dp0hardware_info.ps1"
endlocal
文件二 hardware_info.ps1
$Output = @()
$Output += "CPU Information:"
$Output += Get-WmiObject Win32_Processor | Format-Table Name, Manufacturer, MaxClockSpeed, NumberOfCores
$Output += "Memory Information:"
$Output += (Get-WmiObject Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum / 1GB
$Output += "Disk Drives:"
$Output += Get-WmiObject Win32_DiskDrive | Format-Table DeviceID, Size, MediaType
$Output += "Bios Information:"
$Output += Get-WmiObject Win32_BIOS | Format-Table Manufacturer, SerialNumber, SMBIOSBIOSVersion
$Output += "Baseboard Information:"
$Output += Get-WmiObject Win32_BaseBoard | Format-Table Manufacturer, Product, Version
$Output += "Operating System Information:"
$Output += Get-WmiObject Win32_OperatingSystem | Format-Table CSName, OSArchitecture, Version
$Output += "Network Adapter Configuration:"
$Output += Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true } | Format-Table Description, IPAddress, IPSubnet
$Output += "Video Controller Information:"
$Output += Get-WmiObject Win32_VideoController | Format-Table Name, AdapterRAM, VideoModeDescription
$Output += "USB Devices:"
$Output += Get-WmiObject Win32_USBControllerDevice | Format-Table DeviceID, Name
$Output += "Battery Information:"
$Output += Get-WmiObject Win32_Battery | Format-Table BatteryStatus, EstimatedChargeRemaining, EstimatedTimeOnBattery
$Output | Out-File -FilePath "D:\temp\hardware_info.txt" -Encoding UT
运行 hardware_info.bat 文件 (双击文件即可!)

查看输出结果

文件内容如下
CPU Information:
Name Manufacturer MaxClockSpeed NumberOfCores
---- ------------ ------------- -------------
11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz GenuineIntel 2803 4
Memory Information:
16
Disk Drives:
DeviceID Size MediaType
-------- ---- ---------
\\.\PHYSICALDRIVE0 512105932800 Fixed hard disk media
Bios Information:
Manufacturer SerialNumber SMBIOSBIOSVersion
------------ ------------ -----------------
LENOVO PF4DDCER N3WET18W (1.10 )
Baseboard Information:
Manufacturer Product Version
------------ ------- -------
LENOVO 20W1A0WCCD SDK0T76479 WIN
Operating System Information:
CSName OSArchitecture Version
------ -------------- -------
IASIA-SZNB-004 64 位 10.0.19045
Network Adapter Configuration:
Description IPAddress
----------- ---------
Intel(R) Ethernet Connection (13) I219-V {192.168.50.8, fe80::b2ac:51c3:9e48:863b, 2409:8a55:2ef6:6660:5d58:cbec:de4...
Hyper-V Virtual Ethernet Adapter {172.22.208.1, fe80::2f04:dff6:2beb:c05c}
Video Controller Information:
Name AdapterRAM VideoModeDescription
---- ---------- --------------------
Intel(R) Iris(R) Xe Graphics 134217728 1920 x 1080 x 4294967296 种颜色
USB Devices:
DeviceID Name
-------- ----
Battery Information:
BatteryStatus EstimatedChargeRemaining EstimatedTimeOnBattery
------------- ------------------------ ----------------------
2 94