Submitted By: Richard Fantozzi

Sets a static IP address, subnet mask, default gateway and, optionally, a default DNS server for a specified network connection.

Visual Basic
Edit|Remove
@Echo OFF
echo [required] First Parameter %1 is the Static IP Address
echo [required] Second Parameter %2 is the NetMask
echo [required] Third Parameter %3 is the Default Gateway
echo [optional] Fourth Parameter %4 is the DNS Server

If [%1] == [] GOTO QUIT
If [%2] == [] GOTO QUIT
If [%3] == [] GOTO QUIT

echo Starting %0

Echo ....................Setting IP address on Local Area Connection to %1 with NetMask %2
netsh interface ip set address name="Local Area Connection" source=static addr=%1 mask=%2
Echo ....................Setting Gateway on Local Area Connection to %3 
netsh interface ip set address name="Local Area Connection" gateway=%3 gwmetric=1
 
If [%4] == [] GOTO QUIT
Echo ....................Setting DNS on Local Area Connection to %4
netsh interface ip set dns name="Local Area Connection" source=static addr=%4 register=primary

GOTO QUIT

:QUIT
ECHO ON