to get a new IP address or default gateway
The ipconfig /renew command does this. check this. NETSH
See this example for setting DNS address manually via command:netsh
netsh interface ip set dns "Local Area Connection" static 192.168.0.200
configure your NIC to dynamically obtain its DNS settings ():* Obtain DNS server address automatically
netsh interface ip set dns "Local Area Connection" dhcp
and to set the setting:* Obtain an IP address automatically
netsh interface ip set address "Local Area Connection" dhcp
More info: read this Configure TCP/IP from the Command Prompt and How to change IP address from command prompt.
This is assuming 3 things.
1) The network adapter you're trying to change the IP for is "local area connection". It could also be "local area connection 2" or "wireless network connection". Look in your control panel for the correct name.
2) The IP you want to set is 192.168.0.101, change this to whatever IP to want to use.
3) The default gateway and dns are the same IP. If you are using some kind of router they usually are. Change this to match your network config found with the command ipconfig /all
Here is example of batch file that I have created for your problem solutions: just change the command after the type labelscon1:
How to create batch file:
paste this code in notepad and save it as "test.bat"
Note: Change your connection names to your "local area connection" name"wireless connection"
@ECHO off
cls
:start
ECHO.
ECHO 1. Change Connection1 Static IP
ECHO 2. Change Connection2 Static IP
ECHO 3. Change Connection3 Static IP
ECHO 4. Obtain an IP address automatically
ECHO 5. Exit
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto con1
if '%choice%'=='2' goto con2
if '%choice%'=='3' goto con3
if '%choice%'=='4' goto autosearch
if '%choice%'=='5' goto end
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:con1
ECHO Connecting Connection 1
netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1
goto end
:con2
ECHO Connecting Connection 2
netsh interface ip set address "Local Area Connection1" static 192.168.0.10 255.255.255.0 192.168.0.1 1
goto end
:con3
ECHO Connecting Connection 3
netsh interface ip set address "Local Area Connection2" static 192.168.0.10 255.255.255.0 192.168.0.1 1
goto end
:autosearch
ECHO obtaining auto IP
ipconfig /renew "Local Area Connection"
goto end
:bye
ECHO BYE
goto end
:end
Hope this help you.. for more reference check this Set Your IP Address Via Batch File