Skip to content

Instantly share code, notes, and snippets.

@Noxsios
Last active September 13, 2020 13:26
Show Gist options
  • Save Noxsios/07ea0631dddc6eac43fd4e170c875ee1 to your computer and use it in GitHub Desktop.
Save Noxsios/07ea0631dddc6eac43fd4e170c875ee1 to your computer and use it in GitHub Desktop.
Batch file to change computer IP
@ECHO OFF
ECHO.
ECHO Choose an IP configuration option:
ECHO [1] Set Custom
ECHO [2] DHCP
ECHO [3] DEVICE 1
ECHO [4] DEVICE 2
ECHO [5] Exit
ECHO.
:choice
SET /P C=[1,2,3,4,5]?
for %%? in (1) do if /I "%C%"=="%%?" goto 1
for %%? in (2) do if /I "%C%"=="%%?" goto 2
for %%? in (3) do if /I "%C%"=="%%?" goto 3
for %%? in (4) do if /I "%C%"=="%%?" goto 4
for %%? in (5) do if /I "%C%"=="%%?" goto 5
goto choice
:1
@ECHO off
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 "Setting Static IP Information"
netsh interface ip set address "Ethernet" static %IP_Addr% %Sub_Mask% %D_Gate% 1
ECHO Here are the new settings for %computername%:
netsh interface ipv4 show addresses "Ethernet"
pause
goto end
:2
@ECHO OFF
ECHO Resetting IP Address and Subnet Mask For DHCP
netsh int ip set address name="Ethernet" source=dhcp
netsh set dnsservers name="Ethernet" source=dhcp
ipconfig /release
ipconfig /renew
ECHO Here are the new settings for %computername%:
netsh interface ipv4 show addresses "Ethernet"
pause
goto end
:3
@ECHO off
ECHO "Changing to DEVICE 1 Management "
netsh interface ip set address "Ethernet" static 172.16.0.2 255.255.255.0 172.16.0.1 1
ECHO Here are the new settings for %computername%:
netsh interface ipv4 show addresses "Ethernet"
ECHO "Follow the DEVICE 1 to continue set-up."
start iexplore.exe http://172.16.0.1
pause
goto end
:4
@ECHO off
ECHO "Changing to DEVICE 2 Management "
netsh interface ip set address "Ethernet" static 192.168.1.2 255.255.255.0 192.168.1.1 1
ECHO Here are the new settings for %computername%:
netsh interface ipv4 show addresses "Ethernet"
ECHO "Follow the DEVICE 2 guide to continue set-up."
start iexplore.exe https://192.168.1.1
pause
goto end
:5
goto end
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment