Network Interface Control

:: Network Interface Control                 
::           V2.0                                    

set programname=Network Interface Control
@ECHO OFF

:: Sets the title of the window
title %programname%
color 02 
:: Clears the window incase there is anything there
cls

:: Prints to the window what we are doing
ECHO %programname%
ECHO.
ECHO.

@setlocal EnableDelayedExpansion
@goto MenuList

:MenuList
REM cls

Set "INPUT="
Set "i=0"

Echo Active Network Interfaces  
Echo(

Rem | Get NetConnectionID To String
For /F "Tokens=* Skip=1" %%A In ('WMIC NIC Get NetConnectionID') Do (

    Rem | Remove Empty Lines
    For /F "Tokens=*" %%B In ("%%A") Do (

        Rem | Set Strings
        Set /A "i+=1"

        Rem | Save Variable As String
        Set "Num!i!=%%B"

        Rem | Print String To Console
        Echo   !i! - %%B

    )
)
Echo   0 - Exit

Echo(
Set /P INPUT=Select a Network Interface: 
IF /I "!INPUT!"=="0" GOTO :EOF

Rem | Check For Valid Listing
IF /I "!Num%INPUT%!"=="" (

    Rem | Number Not Listed!
    Echo(
    Echo ERROR: Number Was Not On The List.

    Pause>NUL
    goto MenuList

)

REM cls

Rem | Set String Based On Number
Set "INPUT=!Num%INPUT%!"

Rem | Remove Spaces From End Of String
for /l %%A in (1,1,100) do (if "!INPUT:~-1!"==" " set INPUT=!INPUT:~0,-1!)
Set "net_int=!INPUT!"

Echo !net_int! Selected
echo.
echo.

:: Choose IP config for selected interface
echo Choose IP Configuration for !net_int!:
echo.
echo 1 - Static IP
echo 2 - DHCP
echo.

:choice
SET /P C=Select Configuration:
for %%? in (1) do if /I "%C%"=="%%?" goto 1
for %%? in (2) do if /I "%C%"=="%%?" goto 2
goto choice

REM Set choosen IP config for selected interface
:1
@echo off
echo Enter Static IP Address:
set /p IP_Addr=

echo Setting Static IP...
netsh interface ip set address "!net_int!" static %IP_Addr% 255.255.0.0 192.168.1.1 
goto ipconfig

:2
@ECHO OFF
ECHO Resetting IP Address and Subnet Mask on !net_int! to DHCP
netsh int ip set address name = "!net_int!" source = dhcp
ipconfig /renew
goto ipconfig

REM Show New ipconfig for selected interface
:ipconfig
ECHO %computername% - !net_int! set to:
netsh interface ip show addresses "!net_int!"


goto end

:end
pause