Nov 25, 2011

Change IP using a script or command line in windows


Try This out:

@echo off

REM # Created by Thilina  Piyasundara.

set /P asda=Do you want to change the IP (y/n) : 

if "%1" == "yes" (
 ECHO Setting IP Address
 netsh int ip set address name = "Local Area Connection" source = static addr = 192.168.1.2 mask = 255.255.255.0

 ECHO Setting Gateway
 netsh int ip set address name = "Local Area Connection" gateway = 192.168.2.250 gwmetric = auto

 ECHO Setting Primary DNS
 netsh int ip set dns name = "Local Area Connection" source = static addr = 192.168.2.1
 
 GOTO SETSETTINGS
)

if not "%1" == "yes" (
 ECHO Nothing happened.
)

:SETSETTINGS
netsh int ip show config
:end
 
pause

Use the netsh commands to do the same thing in the command line.

No comments:

Post a Comment

Your comments are always welcome ...