Hi friends,
I was frequently changing my system network from static to dynamic.
I was fed-up with the manual changes by entering the static IP address and changing it to dynamic.
I though of creating a batch file, which requests user to select options and proceed further.
I found something on Internet, just modified it for my purpose and thought of sharing with you all.
- Check your network name
- cmd> netsh interface show interface
- It will list all the network interfaces connected to your system
- Select the network which you want to change the settings
- Modify the below code with appropriate network name, IP address, subnet, gateway and DNS server
@echo off
set NETWORK="Local Area Connection"
set IP=10.9.40.95
set SUBNET=255.255.255.0
set GATEWAY=10.9.40.47
set DNSSERVER=192.168.178.1
echo Choose:
echo [S] Set Static IP
echo [D] Set DHCP
echo.
:choice
SET /P C=[S,D]?
for %%? in (S) do if /I "%C%"=="%%?" goto S
for %%? in (D) do if /I "%C%"=="%%?" goto D
goto choice
:S
@echo off
echo "Setting Static IP Address, Subnet Mask and DNS Server"
netsh interface ip set address %NETWORK% static %IP% %SUBNET% %GATEWAY% 1
netsh interface ip set dnsservers %NETWORK% static %DNSSERVER% primary
netsh interface ip show config
pause
goto end
:D
@echo off
echo "Resetting IP Address, Subnet Mask and DNS server For DHCP"
netsh interface ip set address name=%NETWORK% dhcp
netsh interface ip set dns %NETWORK% dhcp
ipconfig /renew
echo "New IP Address, Subnet Mast and DNS Server for %computername%:"
netsh interface ip show config
pause
goto end
:end
Now enjoy the feature of changing IP address with 3 clicks
Please send your feedback and comments to psrdotcom@gmail.com
Blogger Labels:
Change,
DHCP,
vice,
Windows,
Command,
Line,
Batch,
script,
system,
user,
options,
Internet,
purpose,
Check,
interface,
interfaces,
Select,
settings,
Modify,
gateway,
server,
NETWORK,
Local,
Area,
Connection,
SUBNET,
DNSSERVER,
Choose,
Static,
Mask,
Mast,
feedback,
netsh,
goto,
config