15# ygqiang
此代碼適用雙網卡、雙IP、雙DNS,試試看!- @ECHO OFF&Setlocal EnableDelayedExpansion
- FOR /F "tokens=1,2* delims==" %%A IN ('WMIC Path Win32_ComputerSystem Get Domain^,Name /Value 2^>Nul') DO (
- IF /I "%%A"=="Domain" SET "Domain=%%B"
- IF /I "%%A"=="Name" SET "Name=%%B"&ECHO.電腦名稱: !Name:~,-1!&ECHO.工作群組: !Domain:~,-1!
- )
- FOR /F "tokens=1,2* delims==" %%A IN ('WMIC NICConfig WHERE "IPEnabled=TRUE" GET DefaultIPGateway^,Description^,DNSServerSearchOrder^,IPAddress^,IPSubnet /value 2^>Nul') DO (
- IF /I "%%A"=="DefaultIPGateway" SET "Gateway=%%B"
- IF /I "%%A"=="Description" SET "CardName=%%B"
- IF /I "%%A"=="DNSServerSearchOrder" SET "DNS=%%B"
- IF /I "%%A"=="IPAddress" SET "IP=%%B"
- IF /I "%%A"=="IPSubnet" SET "Subnet=%%B"&ECHO.網卡名稱: !CardName:~,-1!&ECHO.IP 位址: !IP:~1,-2!&ECHO.網路遮罩: !Subnet:~1,-2!&ECHO.預設閘道: !Gateway:~1,-2!&ECHO.DNS 服務: !DNS:~1,-2!&ECHO.
- )
- ECHO. Press any key to exit...
- PAUSE >Nul
复制代码
|