Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Credits 1,185 Posts 438 Joined 2006-08-28 12:00 19-year member UID 61449 From 北京
Status Offline
See if the Remote Registry service is turned off. If it's turned off, it won't work. Also, check if the network card's interface name is correct!!! If the Remote Registry service is turned off, the NETSH command won't run successfully.
Credits 5,310 Posts 2,044 Joined 2005-09-26 12:00 20-year member UID 42843 Gender Male From 四川南充
Status Offline
I exported the contents under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces in the registry after setting up the IP, and then imported it when needed to set the IP, but the content seems a bit more!
Credits 430 Posts 177 Joined 2006-09-20 12:00 19-year member UID 63170 From 广东深圳
Status Offline
@echo off
rem eth //eth is the name of the network card, which can be queried in Network Connections, such as "Local Area Connection"
set eth="Local Area Connection"
rem ip //ip is the IP you want to change
set ip=*.*.*.*
rem gateway //gateway is the gateway address
set gateway=*.*.*.*
rem netmasks //netmasks is the subnet mask
set netmasks=255.255.255.0
rem dns //dns is the preferred DNS
set dns=*.*.*.*
rem dns2 //dns2 is the alternate DNS
set dns2=*.*.*.*
echo Changing the local IP to: %ip%, please wait...
rem
if %gateway%==none netsh interface ip set address %eth% static %ip% %netmasks% %gateway% > nul
if not %gateway%==none netsh interface ip set address %eth% static %ip% %netmasks% %gateway% 1 > nul
if %dns%==none netsh interface ip set dns %eth% static %dns%> nul
if not %dns%==none netsh interface ip set dns %eth% static %dns%> nul
if %dns2%==none netsh interface ip add dns %eth% %dns2%> nul
if not %dns2%==none netsh interface ip add dns %eth% %dns2% 2> nul
echo.........................
echo Checking current local IP:
ipconfig
echo.........................
Successfully changed the local IP to %ip%!
pause
close
Credits 5,310 Posts 2,044 Joined 2005-09-26 12:00 20-year member UID 42843 Gender Male From 四川南充
Status Offline
The upstairs made it too complicated. Generally, in a local area network where only the last byte of the IP address is different, you can use the following BAT file!
@echo off
set /p a=Please enter the last byte of the IP address
netsh interface ip set address "Local Area Connection" static The first three bytes of the IP to be changed.%a% Subnet mask Gateway address 1
netsh interface ip set dns "Local Area Connection" static Preferred DNS
netsh interface ip add dns "Local Area Connection" Alternate DNS
netsh interface ip add dns "Local Area Connection" Alternate DNS