IP address switching batch script sharing

Time:2019-11-8

Copy codeThe code is as follows:
@echo off
rem # ———————————-
REM interface IP configuration
rem # ———————————-

Echo “============ IP control management =======================
Echo “= > D: get IP automatically”
Echo “= > H: dormitory IP address: 66.168.1.8”
Echo “= > R: company network IP address: 192.168.250.173”
Echo “please input the corresponding serial number d, h, R, and press enter to finish:”
set /p ch=
if %ch%==””  echo “You input null”&goto :EOF
set case=d,h,t,w>nul
echo %case%|findstr “\<%ch%\>”>nul&if errorlevel 1  goto :err
goto %ch%
goto err

:h
“Bedroom”
echo “configure home ip address gateway,please wait 30 second …”
@Netsh int ip set address “local connection” static 66.168.1.8 255.255.255.0 66.168.1.1 1 > nul
@Netsh int ip set DNS “local connection” static 66.168.1.1 primary > nul
echo home ip configure is done
goto :EOF

:r
:: “company network”
echo “configure transport ip address gateway,please wait 30 second …”
@Netsh int ip set address “local connection” static 192.168.250.173 255.255.255.0 192.168.250.1 1 > nul
echo transport ip configure is done
goto :EOF

:d
: DHCP “get IP address automatically”
echo “configure transport ip address gateway,please wait 30 second …”
@Netsh int ip set address “local connection”
@Netsh int ip set DNS “local connection” DHCP > nul

:err
:: “error”
echo your input “%ch%” ,no this argument ! please input h or w!  game over
REM – end of interface IP configuration