I have come up with a batch script using which you can switch between these network settings without having to change them manually whenever your work location changes. All that has to be done to copy the below script into a file and name it *.bat and just double click it. You might have to key in your work location as an arg when you run this.
Don't forget to define the following variables varip, varsm, vargw, vardns1 and vardns2 with your network specific entries. (Your service provider must have provided you with these entries)
******** COPY THE SOURCE BELOW ********
@ECHO OFF
ECHO Change network setting for (Home/Work)?
set/p "cho=>"
if %cho%==Home goto HOME
if %cho%==HOME goto HOME
if %cho%==Work goto WORK
if %cho%==WORK goto WORK
:HOME
set varip=
set varsm=
set vargw=
ECHO Change network setting for (Home/Work)?
set/p "cho=>"
if %cho%==Home goto HOME
if %cho%==HOME goto HOME
if %cho%==Work goto WORK
if %cho%==WORK goto WORK
:HOME
set varip=
set varsm=
set vargw=
set vardns1=
set vardns2=
REM ***** You don’t need to change anything below this line! ******
ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm%
ECHO Setting Gateway
netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1
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 DISPLAY
:WORK
ECHO Setting IP Address
netsh int ip set address name = "Local Area Connection" source = dhcp
ECHO Setting DNS
netsh int ip set dns name = "Local Area Connection" source = dhcp
GOTO DISPLAY
:DISPLAY
ECHO Here are the new settings for %computername%:
netsh int ip show config
pause.
No comments:
Post a Comment