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-07-17 06:33
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Regarding the issue of P processing to change the network card IP View 2,118 Replies 16
Original Poster Posted 2007-04-29 00:18 ·  中国 新疆 博尔塔拉蒙古自治州 电信
初级用户
Credits 34
Posts 16
Joined 2007-04-23 13:17
19-year member
UID 86201
Gender Male
Status Offline
I always manually change the IP and computer name every time I burn a disc in the internet café.

Recently I made a P processing to automatically change the IP and computer name.

But I want to ask the following:

Some computers have 2 network cards, so there will be "Local Area Connection" and "Local Area Connection 2" or even "Local Area Connection 3".

The command "Netsh interface ip set address 本地连接 static 192.168.1.2 255.255.252.0 192.168.1.1 1" seems to not work.

Is there any way to test: if "Local Area Connection" is connected, set the IP of "Local Area Connection" to the above IP; if "Local Area Connection 2" is connected, change the IP of "Local Area Connection 2"? Because sometimes the network cables are inserted randomly, and the slots where the network cards are inserted are not uniform, resulting in many local connections appearing.

[ Last edited by feixiang9911 on 2007-4-29 at 12:22 AM ]
Floor 2 Posted 2007-04-29 01:49 ·  中国 上海 电信
中级用户
★★
Credits 321
Posts 135
Joined 2007-02-04 04:48
19-year member
UID 78578
Gender Male
Status Offline
Below is a guess, no conditions to test.

On a machine with multiple local links, dump a Netsh interface, then modify it and apply. It should be achievable.
Floor 3 Posted 2007-04-29 02:20 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
netsh intreface show interface|find "Enabled"|find "Private"
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
feixiang9911 +2 2007-04-29 23:20
Floor 4 Posted 2007-04-29 23:23 ·  中国 新疆 博尔塔拉蒙古自治州 电信
初级用户
Credits 34
Posts 16
Joined 2007-04-23 13:17
19-year member
UID 86201
Gender Male
Status Offline
xiexie I'm thinking I'll try again

But you find "Enable" | it doesn't work because it's just not connected. The local connections are all enabled
What is "special" looking for?
Floor 5 Posted 2007-04-30 01:05 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Floor 6 Posted 2007-05-01 02:29 ·  中国 新疆 博尔塔拉蒙古自治州 电信
初级用户
Credits 34
Posts 16
Joined 2007-04-23 13:17
19-year member
UID 86201
Gender Male
Status Offline
Heheh, when will you be able to figure it out?
Floor 7 Posted 2007-05-01 03:42 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
feixiang9911:

The example I provided is incorrect. That is for filtering non - LAN connections. If your computer has only one network card, you can use the ipconfig command to get the name of the active connection

for /f "tokens=3 delims=: " %i in ('ipconfig^|find /i "adapter"') do echo %i
Floor 8 Posted 2007-05-01 06:10 ·  中国 新疆 博尔塔拉蒙古自治州 电信
初级用户
Credits 34
Posts 16
Joined 2007-04-23 13:17
19-year member
UID 86201
Gender Male
Status Offline
I have many network cards. Some have the integrated network card disabled in CMOS, so there is only one network card. If the CMOS network card is enabled, there are 2 network cards, and both are enabled if there are 2 network cards. It's just that the network cables are inserted below or above. I just want to set the IP of the network card with the network cable inserted. You help me take a look.
Floor 9 Posted 2007-05-01 06:30 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
I'm not sure whether it will be displayed as active under ipconfig if the network card isn't plugged in with a network cable. You can test it. I don't dare to unplug the cable on my machine.
Floor 10 Posted 2007-05-01 06:41 ·  中国 广东 广州 海珠区 电信
银牌会员
★★★
Credits 1,206
Posts 517
Joined 2007-03-25 01:18
19-year member
UID 82819
Gender Male
Status Offline
I am like this code without conditional testing...

Just won't write it out. Afraid of being ashamed :)
知,不觉多。不知,乃求知
Floor 11 Posted 2007-05-01 12:33 ·  中国 福建 厦门 电信
初级用户
Credits 97
Posts 45
Joined 2007-01-31 06:02
19-year member
UID 78190
Gender Male
Status Offline
The network card without an Ethernet cable plugged in shows "Disconnected", and only the network card with normal connection shows "Connected".
Floor 12 Posted 2007-05-02 17:05 ·  中国 新疆 博尔塔拉蒙古自治州 电信
初级用户
Credits 34
Posts 16
Joined 2007-04-23 13:17
19-year member
UID 86201
Gender Male
Status Offline
I tried it. Even without plugging in the network cable, it still shows active.
Brothers, is there really no way to solve this problem?
`5`55
Floor 13 Posted 2007-05-03 15:46 ·  中国 广东 广州 黄埔区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
I don't have the conditions for this, but you can test various network-related commands and see the characteristics, such as nbtstat -a localhost, which will list the current connections and IPs.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
feixiang9911 +1 2007-05-09 14:18
Floor 14 Posted 2007-05-04 00:16 ·  中国 福建 泉州 石狮市 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
Is there only one Huiton? Or is it possible to have two Huitons, or all Huitons?
If there is only one Huiton, try the following code
The principle, you can understand by looking at the code yourself


  1. @echo off
  2. for /f "usebackq tokens=1 delims=:" %%i in (`ipconfig^|findstr /n /c:"IP Address"`) do (
  3. for /f "usebackq tokens=1,3* delims=: " %%a in (`ipconfig^|findstr /n /c:"Ethernet adapter"`) do (
  4. if %%i GTR %%a (set 连接=%%c)
  5. )
  6. )
  7. set 连接=%连接::=%
  8. echo %连接%
  9. pause
chenall posted on: 2007-05-04 00:15
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
feixiang9911 +2 2007-05-09 14:18
QQ:366840202
http://chenall.net
Floor 15 Posted 2007-05-04 07:04 ·  中国 广东 广州 黄埔区 电信
中级用户
★★
Credits 326
Posts 152
Joined 2007-05-04 06:16
19-year member
UID 87412
Gender Male
Status Offline
@echo off
title Automatically Modify Network DNS According to Your Local Network Card Name by Bin QQ43142691
::: Here starts getting network card information
@echo off&ipconfig /all >network.ini
::: Here starts judging network card name
@echo off&find "Local Area Connection" network.ini && set netcard=Local Area Connection
@echo off&find "Local Area Connection 1" network.ini && set netcard=Local Area Connection 1
@echo off&find "Local Area Connection 2" network.ini && set netcard=Local Area Connection 2
@echo off&find "Local Area Connection 3" network.ini && set netcard=Local Area Connection 3
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::Modify IP
set slection1=
set slection1=10.0.0.128
netsh interface ip set address name="%netcard%" source=static addr=%slection1% mask=255.255.252.0
::Here starts modifying gateway
set slection2=
set slection2=10.0.0.254
netsh interface ip set address name="%netcard%" gateway=%slection2% gwmetric=0
::Start modifying DNS
@netsh interface ip set dns name="%netcard%" source=static addr=202.96.128.143
@netsh interface ip add dns name="%netcard%" addr=202.96.128.68 index=2
exit

[ Last edited by qq43142691 on 2007-5-3 at 06:05 PM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
feixiang9911 +1 2007-05-09 14:20
Forum Jump: