Skip to content

Instantly share code, notes, and snippets.

@dschense
Last active December 23, 2020 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dschense/67fba39135d8109ce1c788f3257b54af to your computer and use it in GitHub Desktop.
Save dschense/67fba39135d8109ce1c788f3257b54af to your computer and use it in GitHub Desktop.
windows change network
@echo off
REM https://community.spiceworks.com/how_to/320-batch-file-script-to-change-ip-addresses
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 off
echo "Please enter Static IP Address Information"
echo "Static IP Address:"
set /p IP_Addr=
echo "Subnet Mask:"
set /p Sub_Mask=
echo "Default Gateway:"
set /p D_Gate=
echo "Setting Static IP Information"
netsh interface ip set address "Ethernet0" static %IP_Addr% %Sub_Mask% %D_Gate% 1
netsh int ip show config
pause
goto end
:B
@ECHO OFF
ECHO Resetting IP Address and Subnet Mask For DHCP
netsh int ip set address name = "Ethernet0" source = dhcp
ipconfig /renew
ECHO Here are the new settings for %computername%:
netsh int ip show config
pause
goto end
:end
Script END!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment