Script to configure network on Windows
@echo off
set IP_Ending=9
set Interface_Name="Ethernet"
echo Here are the new settings for %computername%:
netsh int ip show config %Interface_Name%
goto check_Permissions
:check_Permissions
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed.
goto current
) else (
echo Failure: Current permissions inadequate.
echo Right click on the icon then click "Run as Administrator."
pause
goto end
)
:usage
echo Choose:
echo [1] Set Static IP User defined
echo [2] Set DHCP
echo [3] Set Static IP 192.168.1.%IP_Ending%
echo [4] Set Static IP 192.168.123.%IP_Ending%
echo [5] Set Static IP 192.168.250.%IP_Ending%
echo [6] Set Static IP 10.11.12.%IP_Ending%
echo [7] Set Static IP 192.168.2.%IP_Ending%
echo [c] Display current settings
echo [q] Quit
echo .
:choice
SET /P C=[1,2,3,4,5,6,7,c,q]?
for %%? in (1) do if /I "%C%"=="%%?" goto A
for %%? in (2) do if /I "%C%"=="%%?" goto B
for %%? in (3) do if /I "%C%"=="%%?" goto C
for %%? in (4) do if /I "%C%"=="%%?" goto D
for %%? in (5) do if /I "%C%"=="%%?" goto E
for %%? in (6) do if /I "%C%"=="%%?" goto F
for %%? in (7) do if /I "%C%"=="%%?" goto G
for %%? in (c) do if /I "%C%"=="%%?" goto current
for %%? in (q) do if /I "%C%"=="%%?" goto end
goto choice
:A
@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 %Interface_Name% static %IP_Addr% %Sub_Mask% %D_Gate% 1
goto current
:B
@echo OFF
echo Resetting IP Address and Subnet Mask For DHCP
netsh int ip set address name = %Interface_Name% source = dhcp
ipconfig /renew
goto current
:C
@echo OFF
echo Set IP Address and Subnet Mask For 192.168.1.%IP_Ending%
echo "Setting Static IP Information"
netsh interface ip set address %Interface_Name% static 192.168.1.%IP_Ending% 255.255.255.0 192.168.1.1 1
goto current
:D
@echo OFF
echo Set IP Address and Subnet Mask For 192.168.123.%IP_Ending%
echo "Setting Static IP Information"
netsh interface ip set address %Interface_Name% static 192.168.123.%IP_Ending% 255.255.255.0 192.168.123.1 1
goto current
:E
@echo OFF
echo Set IP Address and Subnet Mask For 192.168.250.%IP_Ending%
echo "Setting Static IP Information"
netsh interface ip set address %Interface_Name% static 192.168.250.%IP_Ending% 255.255.255.0 192.168.250.1 1
goto current
:F
@echo OFF
echo Set IP Address and Subnet Mask For 10.11.12.%IP_Ending%
echo "Setting Static IP Information"
netsh interface ip set address %Interface_Name% static 10.11.12.%IP_Ending% 255.255.255.0 10.11.12.1 1
goto current
:G
@echo OFF
echo Set IP Address and Subnet Mask For 192.168.2.%IP_Ending%
echo "Setting Static IP Information"
netsh interface ip set address %Interface_Name% static 192.168.2.%IP_Ending% 255.255.255.0 192.168.2.1 1
goto current
:current
echo Here are the new settings for %computername%:
netsh int ip show config %Interface_Name%
goto usage
:end