Tuesday, July 3, 2012

Batch file for IP settings


@ECHO OFF

set varip=192.168.23.80
set varsm=255.255.255.0
set vargw=192.168.23.9
set vardns1=10.32.192.11
set vardns2=168.126.63.1


@echo off
echo Choose:
echo [A] Set Internet Static IP
echo [B] Set static IP
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 This fanciness is brought to you by Nagaraj!
ECHO Internet IP Settings

ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm% gateway = %vargw%

ECHO Setting Primary DNS
netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%

ECHO Setting Secondary DNS
netsh int ip add dns name = "Local Area Connection" addr = %vardns2%
goto end

:B
set varip=10.90.54.134
set varsm=255.255.255.0
set vargw=10.90.54.1
set vardns1=10.32.192.11
set vardns2=168.126.63.1

ECHO  IP Settings

ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm% gateway = %vargw%

ECHO Setting Primary DNS
netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%

ECHO Setting Secondary DNS
netsh int ip add dns name = "Local Area Connection" addr = %vardns2%
goto end
:end
rem ECHO Here are the new settings for %computername%:
netsh int ip show config

pause

No comments:

Post a Comment