Skip to content

Instantly share code, notes, and snippets.

@maravedi
Created April 20, 2017 15:35
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maravedi/8a99f04a58208a6a82627e2919c01ba7 to your computer and use it in GitHub Desktop.
Save maravedi/8a99f04a58208a6a82627e2919c01ba7 to your computer and use it in GitHub Desktop.
Batch Script to Change from Static IP to DHCP
@echo off
echo Choose:
echo [A] Set Static IP to XX.XX.XX.XX
echo [B] Set DHCP
echo ================================
:choice
SET /P C=[A or B]?
if [%C%]==[A] goto A
if [%C%]==[B] goto B
goto choice
:A
@echo off
echo Setting static IP address: XX.XX.XX.XX
netsh interface ip set address "Local Area Connection" static XX.XX.XX.XX 255.255.255.0 XX.XX.XX.YY
netsh interface ip add dns "Local Area Connection" addr="8.8.4.4"
netsh interface ip add dns "Local Area Connection" addr="8.8.8.8"
netsh interface ip show config "Local Area Connection"
pause
goto end
:B
@echo off
echo Enabling DHCP
netsh interface ip set address "Local Area Connection" source=dhcp
netsh interface ip set dnsservers "Local Area Connection" source=dhcp
netsh interface ip show config "Local Area Connection"
pause
goto end
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment