China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

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!

中国DOS联盟论坛
The time now is 2026-08-01 20:07
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » About modifying the gateway directly with batch processing View 3,015 Replies 6
Original Poster Posted 2006-06-16 10:43 ·  中国 广东 广州 白云区 电信
初级用户
Credits 100
Posts 34
Joined 2006-04-05 05:13
20-year member
UID 53340
Gender Male
Status Offline
Can batch processing directly modify the gateway of the XP system? It can be done by manually entering NETSH in the CMD and then entering commands step by step. But I can't figure out how to do it in batch processing. Moreover, I need the IP to remain unchanged and only the gateway to be changed. I ask you all, is there a good way? Thanks in advance
Floor 2 Posted 2006-06-16 11:04 ·  中国 广西 河池 电信
初级用户
Credits 80
Posts 29
Joined 2006-05-03 03:20
20-year member
UID 54852
Status Offline
Young man, you didn't post in the right place. Search the forum, I answered this question before.
Floor 3 Posted 2006-06-16 11:11 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
netsh interface ip set address "Local Area Connection" static IP address subnet mask default gateway 1
Floor 4 Posted 2006-06-16 11:15 ·  中国 广东 广州 白云区 电信
初级用户
Credits 100
Posts 34
Joined 2006-04-05 05:13
20-year member
UID 53340
Gender Male
Status Offline
Dude, I've searched and read, but it's not really working out.

netsh interface ip set address is for changing the IP. Now the problem is I can't pre - determine what the IP of the machine running this batch at that time will be, and I can't change its IP, only its gateway.

I have an idea myself, using IPCONFIG/ALL >1.TXT combined with FINDSTR to find the IP and then using NETSH, but I can't make this idea work. Please give more advice.

Thanks
Floor 5 Posted 2006-06-16 13:15 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
for /f "tokens=2 delims=:" %%i in ('"ipconfig|findstr /I /c:"ip address""') do set a=%%i
Isn't this okay?
Floor 6 Posted 2006-06-17 15:26 ·  中国 山西 大同 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline

───────────────── Moderation Log ─────────────────
Performed by: Will Sort
Action: Move Topic: From DOS Troubleshooting & Discussion (Help Desk)
Explanation: According to the topic content classification, it is more suitable to be posted in this forum area
Punishment: Deducted 6 points of rewards for posting this topic, and 2 points of points deducted for forum area violations
───────────────── Moderation Log ─────────────────
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 7 Posted 2006-06-19 15:02 ·  中国 广东 东莞 电信
初级用户
★★
Credits 118
Posts 66
Joined 2005-10-21 03:27
20-year member
UID 43827
Status Offline
@echo off
color 0b
echo.
echo.
echo. ==============================================================
echo.
echo.
echo. In order to optimize the online quality in recent days, this internet cafe has made corresponding adjustments to the online line!
set /p var= Please press any key to start switching!
echo.
echo. ==============================================================
echo.

echo.
echo. Changing to a faster line for you, please wait ........
echo. .............................................................
netsh i i set address name="Local Area Connection" gateway=192.168.0.254 gwmetric=0
Forum Jump: