BATバッチでIPアドレスを判断してネットワークカードを有効、無効にする

 

サンプルコード:

@ECHO OFF
for /f “tokens=2 delims=:" %%i in ('ipconfig^|findstr “Address"') do set ip=%%i
SET ip=%ip:~1%
set id=%ip:~0,3%
ECHO Current IP Address : %ip%
if NOT “%id%"=="10." goto FIXIPADDR
ECHO It seems OK:-)
goto END

:FIXIPADDR
ECHO Fix DHCP Configuration
ECHO Please wait…
ipconfig /release>NUL 1>NUL 2>NUL
ipconfig /renew>NUL 1>NUL 2>NUL

ECHO All Done
:END
PAUSE

Source

Posted by arkgame