标题: [文本处理] 求大神帮忙改下批处理输出结果排版 [打印本页]
作者: dircls1318 时间: 2020-5-12 11:50 标题: 求大神帮忙改下批处理输出结果排版
- @ECHO OFF&Setlocal EnableDelayedExpansion
- set _Name=计算机名----&set _Domain=工作组------&set _IPAddress=IP地址------
- set _IPSubnet=子网掩码----&set _DefaultIPGateway=网关--------&set _DNSServerSearchOrder=DNS---------
- FOR /F "tokens=*" %%A IN ('WMIC Path Win32_ComputerSystem Get Domain^,Name /Value 2^>Nul') DO (
- FOR /F "tokens=*" %%i in ("%%A") do set %%i
- )
- FOR /F "tokens=*" %%A IN ('WMIC NICConfig WHERE "IPEnabled=TRUE" GET DefaultIPGateway^,Description^,DNSServerSearchOrder^,IPAddress^,IPSubnet /value 2^>Nul') DO (
- FOR /F "tokens=*" %%i in ("%%A") do set %%i
- )
-
- for %%i in (Name Domain IPAddress IPSubnet DefaultIPGateway DNSServerSearchOrder) do (
- set %%i=!%%i:{=!
- set %%i=!%%i:}=!
- set %%i=!%%i:"=!
- echo !_%%i!: !%%i:,= !
- )
-
- @echo off&setlocal enabledelayedexpansion
- echo.&echo.
- for /f "skip=1 tokens=1,* delims= " %%a in ('wmic nic where ^(adaptertype like "ethernet ___._" and netconnectionstatus^="2"^) get name^,macaddress') do (set /A N+=1&set _!N!MAC=%%a&call echo.[!N!] %%b %%a)
- echo.&echo.
- IF !N! EQU 1 set MAC_=!_1MAC!&goto :loop
-
- wmic DISKDRIVE get SerialNumber /value
-
-
- pause>nul
复制代码
这是输出结果
计算机名----: WIN7-64825
工作组------: WORKGROUP
IP地址------: 192.168.10.130
子网掩码----: 255.255.255.0 64
网关--------: 192.168.10.1
DNS---------: 114.114.114.114
[1] Sangfor FastIO Ethernet Adapter 68:01:28:00:EF:69
[2]
SerialNumber=343238333039
SerialNumber=343238333039
求大神帮忙改下输出结果能排版最好如这样:
计算机名----: WIN7-64825
工作组------: WORKGROUP
IP地址------: 192.168.10.130
子网掩码----: 255.255.255.0 64
网关--------: 192.168.10.1
DNS---------: 114.114.114.114
MAC地址:****
硬盘序列号:****
作者: smss 时间: 2020-5-12 14:29
本帖最后由 smss 于 2020-5-13 02:56 编辑
- @echo off&Setlocal EnableDelayedExpansion
- set _Name=计算机名----&set _Domain=工作组------&set _IPAddress=IP地址------&set _IPSubnet=子网掩码----&set _DefaultIPGateway=网关--------&set _DNSServerSearchOrder=DNS---------
- FOR /F "tokens=*" %%A IN ('WMIC Path Win32_ComputerSystem Get Domain^,Name /Value 2^>Nul') DO (FOR /F "tokens=*" %%i in ("%%A") do set %%i)
- FOR /F "tokens=*" %%A IN ('WMIC NICConfig WHERE "IPEnabled=TRUE" GET DefaultIPGateway^,Description^,DNSServerSearchOrder^,IPAddress^,IPSubnet /value 2^>Nul') DO (FOR /F "tokens=*" %%i in ("%%A") do set %%i)
- for %%i in (Name Domain IPAddress IPSubnet DefaultIPGateway DNSServerSearchOrder) do (set %%i=!%%i:{=!
- set %%i=!%%i:}=!
- set %%i=!%%i:"=!
- echo !_%%i!: !%%i:,= !)
- set "index=0"
- for /f "skip=1 delims=" %%a in ('wmic path Win32_PhysicalMedia get SerialNumber') do (set /a "index+=1"
- call set "硬盘序列号%%index%%=%%a")
- set 硬盘序列号
- pause
复制代码
作者: dircls1318 时间: 2020-5-13 11:28
回复 2# smss
谢谢大神
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |