Created
September 14, 2020 14:58
-
-
Save jimdiroffii/da41ebf0d40b97f86337c7f12bac8bc5 to your computer and use it in GitHub Desktop.
Interactively set an IP address in the CMD line of Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo Choose: | |
echo [A] Set Static IP | |
echo [B] Set DHCP | |
echo. | |
:choice | |
SET /P C=[A,B]? | |
for %%? in (A) do if /I "%C%"=="%%?" goto A | |
for %%? in (B) do if /I "%C%"=="%%?" goto B | |
goto choice | |
:A | |
echo Please enter Static IP Address Information | |
echo Static IP Address: | |
set /p IP_Addr= | |
echo Default Gateway: | |
set /p D_Gate= | |
echo Subnet Mask: | |
set /p Sub_Mask= | |
echo Primary DNS: | |
set /p P_DNS= | |
echo Secondary DNS: | |
set /p S_DNS= | |
echo Setting Static IP Information | |
netsh interface ip set address "LAN" static %IP_Addr% %Sub_Mask% %D_Gate% 1 | |
netsh interface ip set dnsservers name="LAN" static %P_DNS% | |
netsh interface ip set dnsservers name="LAN" static %S_DNS% index=2 | |
ECHO Here are the new settings for %computername%: | |
netsh int ip show config | |
pause | |
goto end | |
:B | |
ECHO Resetting IP Address and Subnet Mask For DHCP | |
netsh interface ip set address name = "LAN" source = dhcp | |
netsh interface ip set dnsservers name="LAN" source = dhcp | |
ipconfig /release | |
ipconfig /renew | |
ECHO Here are the new settings for %computername%: | |
netsh int ip show config | |
pause | |
goto end | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment