[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] 求大神帮忙改下批处理输出结果排版

  1. @ECHO OFF&Setlocal EnableDelayedExpansion
  2. set _Name=计算机名----&set _Domain=工作组------&set _IPAddress=IP地址------
  3. set _IPSubnet=子网掩码----&set _DefaultIPGateway=网关--------&set _DNSServerSearchOrder=DNS---------
  4. FOR /F "tokens=*" %%A IN ('WMIC Path Win32_ComputerSystem Get Domain^,Name /Value 2^>Nul') DO (
  5.     FOR /F "tokens=*" %%i in ("%%A") do set %%i
  6. )
  7. FOR /F "tokens=*" %%A IN ('WMIC NICConfig WHERE "IPEnabled=TRUE" GET DefaultIPGateway^,Description^,DNSServerSearchOrder^,IPAddress^,IPSubnet /value 2^>Nul') DO (
  8.    FOR /F "tokens=*" %%i in ("%%A") do set %%i
  9. )
  10. for %%i in (Name Domain IPAddress IPSubnet DefaultIPGateway DNSServerSearchOrder) do (
  11.     set %%i=!%%i:{=!
  12.     set %%i=!%%i:}=!
  13.     set %%i=!%%i:"=!
  14.     echo !_%%i!: !%%i:,=  !  
  15. )
  16. @echo off&setlocal enabledelayedexpansion
  17. echo.&echo.
  18. 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)
  19. echo.&echo.
  20. IF !N! EQU 1 set MAC_=!_1MAC!&goto :loop
  21. wmic DISKDRIVE get SerialNumber /value
  22. 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-13 02:56 编辑
  1. @echo off&Setlocal EnableDelayedExpansion
  2. set _Name=计算机名----&set _Domain=工作组------&set _IPAddress=IP地址------&set _IPSubnet=子网掩码----&set _DefaultIPGateway=网关--------&set _DNSServerSearchOrder=DNS---------
  3. 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)
  4. 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)
  5. for %%i in (Name Domain IPAddress IPSubnet DefaultIPGateway DNSServerSearchOrder) do (set %%i=!%%i:{=!
  6. set %%i=!%%i:}=!
  7. set %%i=!%%i:"=!
  8. echo !_%%i!: !%%i:,=  !)
  9. set "index=0"
  10. for /f "skip=1 delims=" %%a in ('wmic path Win32_PhysicalMedia get SerialNumber') do (set /a "index+=1"
  11. call set "硬盘序列号%%index%%=%%a")
  12. set 硬盘序列号
  13. pause
复制代码

TOP

回复 2# smss


    谢谢大神

TOP

返回列表