View Single Post
  #7  
Old 02-21-2012, 05:15 AM
aladdin aladdin is offline
Senior Member
 
Join Date: Sep 2008
Posts: 66
Default

I combined your lines in my batch file which is given below:

Code:
@ECHO OFF
 
set varip=10.0.83.88
set varsm=255.255.255.224
set vargw=10.0.83.65
set vargw2=10.0.83.66
set vardns1=10.0.1.21
set vardns2=10.0.83.66
 
REM ***** You don’t need to change anything below this line! ******
 
ECHO This fanciness is brought to you by Saman Sadeghi!

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 = 

ECHO Setting Alternate Gateway
netsh int ip add address name="Local Area Connection" gateway = %vargw2% gwmetric=50

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%
 
ECHO Here are the new settings for %computername%:
netsh int ip show config
 
pause
Things are getting more complicated
Few things happened after running the final batch fille:

1. An error occurred at the end after running the batch file:
Network Command Shell has encountered a problem and needs to close. We are sorry for the inconvenience. Send Error report/Don't Send

2. It assigns Default Gateway field in the following order:
10.0.83.66 Metric = Automatic
10.0.83.65 Metric = 50

I go to Local Area Connection Status > Support and I found Default Gateway = 10.0.83.66 whereas when I go to TCP/IP Properties then I find the following information:
IP Address: 10.0.83.88
Subnet Mask: 255.255.255.224
Default Gateway: 10.0.83.65

Strange??? And sometimes it says which is as follows:

Code:
Setting IP Address and Subnet Mask
Ok.

Setting Gateway
Ok.

Setting Alternate Gateway

A default gateway with this IP Address already configured on this interface.

Setting Primary DNS
Ok.

Setting Secondary DNS
Ok.
Now I manually add 10.0.83.66 with Metric 50 & 10.0.83.65 with Automatic Metric then I export the settings using the following command:
Code:
netsh -c interface dump > c:\location1.txt
And when I open location1.txt then I find the following information:
Code:
#========================
# Interface configuration
#========================
pushd interface

reset all


popd
# End of interface configuration

#========================
# Interface configuration
#========================
pushd interface ipv6

uninstall


popd
# End of interface configuration



# ----------------------------------
# ISATAP Configuration
# ----------------------------------
pushd interface ipv6 isatap



popd
# End of ISATAP configuration



# ----------------------------------
# 6to4 Configuration
# ----------------------------------
pushd interface ipv6 6to4

reset



popd
# End of 6to4 configuration

#========================
# Port Proxy configuration
#========================
pushd interface portproxy

reset


popd
# End of Port Proxy configuration



# ---------------------------------- 
# Interface IP Configuration         
# ---------------------------------- 
pushd interface ip


# Interface IP Configuration for "Local Area Connection"

set address name="Local Area Connection" source=static addr=10.0.83.88 mask=255.255.255.224
set address name="Local Area Connection" gateway=10.0.83.65 gwmetric=0
add address name="Local Area Connection" gateway=10.0.83.66 gwmetric=50
set dns name="Local Area Connection" source=static addr=10.0.1.21 register=PRIMARY
add dns name="Local Area Connection" addr=10.0.83.66 index=2
set wins name="Local Area Connection" source=static addr=none

popd
# End of interface IP configuration

Last edited by aladdin : 02-21-2012 at 05:44 AM.
Reply With Quote