批处理之获取电脑配置信息

@echo off

chcp 936>nul 2>nul

setlocal enabledelayedexpansion

set /p name=姓名:

set /p type=类型:

set /p use=用途:

@echo 名称: %name% >%name%.txt

@echo 类型: %type% >>%name%.txt

@echo 用途: %use% >>%name%.txt

@echo.>>%name%.txt

@echo.

@rem 电脑名称 制造商

for /f "tokens=1-2 delims==" %%a in ('wmic computersystem get Name^,Manufacturer /value') do (

for /f %%i in ("%%a") do (

if "%%i" == "Name" (

@echo 电脑名称: %%b

set str=%%b

@echo 电脑名称: !str:~0,-1!>>%name%.txt

)

if "%%i" == "Manufacturer" (

@echo 制造商: %%b

set str=%%b

@echo 制造商: !str:~0,-1!>>%name%.txt

)

)

)

@rem 操作系统

for /f "tokens=* delims=" %%a in ('wmic os get Caption /value') do (

for /f %%i in ("%%a") do (

if "%%i" == "Caption" (

@echo 操作系统: %%b

set str=%%b

@echo 操作系统: !str:~0,-1!>>%name%.txt

)

)

)

@echo.>>%name%.txt

@echo.

@rem IP MAC

for /f "tokens=1-2 delims==" %%a in ('wmic nicconfig where "IPEnabled='TRUE'" get IPAddress^,MACAddress /value') do (

for /f %%i in ("%%a") do (

if "%%i" == "IPAddress" (

for /f tokens^=1-3^ delims^={^" %%x in ("%%b") do (

@echo IP地址: %%x

@echo IP地址: %%x>>%name%.txt

)

)

if "%%i" == "MACAddress" (

@echo MAC地址: %%b

@echo MAC地址: !str:~0,-1!>>%name%.txt

)

)

)

@echo.>>%name%.txt

@echo.

@rem CPU型号 CPU核数 CPU线程数

for /f "tokens=1-2 delims==" %%a in ('wmic cpu get Name^,NumberOfCores^,NumberOfLogicalProcessors /value') do (

for /f %%i in ("%%a") do (

if "%%i" == "Name" (

@echo CPU型号: %%b

set str=%%b

@echo CPU型号: !str:~0,-1!>>%name%.txt

)

if "%%i" == "NumberOfCores" (

@echo CPU核数: %%b

set str=%%b

@echo CPU核数: !str:~0,-1!>>%name%.txt

)

if "%%i" == "NumberOfLogicalProcessors" (

@echo CPU线程数: %%b

set str=%%b

@echo CPU线程数: !str:~0,-1!>>%name%.txt

)

)

)

@echo.>>%name%.txt

@echo.

@rem 内存型号 内存大小

for /f "tokens=1-2 delims==" %%a in ('wmic memorychip get PartNumber^,Capacity /value') do (

for /f %%i in ("%%a") do (

if "%%i" == "PartNumber" (

@echo 内存型号: %%b

set str=%%b

@echo 内存型号: !str:~0,-1!>>%name%.txt

)

if "%%i" == "Capacity" (

@echo 内存大小: %%b

set str=%%b

@echo 内存大小: !str:~0,-1!>>%name%.txt

)

)

)

@echo.>>%name%.txt

@echo.

@rem 磁盘名称 磁盘型号 磁盘容量

for /f "tokens=1-2 delims==" %%a in ('wmic diskdrive get Caption^,Model^,Size /value') do (

for /f %%i in ("%%a") do (

if "%%i" == "Caption" (

@echo 磁盘名称: %%b

set str=%%b

@echo 磁盘名称: !str:~0,-1!>>%name%.txt

)

if "%%i" == "Model" (

@echo 磁盘型号: %%b

set str=%%b

@echo 磁盘型号: !str:~0,-1!>>%name%.txt

)

if "%%i" == "Size" (

@echo 磁盘容量: %%b

set str=%%b

@echo 磁盘容量: !str:~0,-1!>>%name%.txt

)

)

)

@echo.>>%name%.txt

@echo.

@rem 显卡名称

for /f "tokens=1-2 delims==" %%a in ('wmic path Win32_VideoController get Name /value') do (

for /f %%i in ("%%a") do (

if "%%i" == "Name" (

@echo 显卡名称: %%b

set str=%%b

@echo 显卡名称: !str:~0,-1!>>%name%.txt

)

)

)

pause

你可能感兴趣的:(批处理之获取电脑配置信息)