![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-25 07:33 |
47,813 topics / 349,918 posts / today 1 new / 48,274 members |
| DOS批处理 & 脚本技术(批处理室) » Regarding the issue of P processing to change the network card IP |
| Printable Version 2,409 / 16 |
| Floor1 feixiang9911 | Posted 2007-04-29 00:18 |
| 初级用户 Posts 16 Credits 34 | |
|
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 ] |
|
| Floor2 honghunter | Posted 2007-04-29 01:49 |
| 中级用户 Posts 135 Credits 321 | |
|
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. |
|
| Floor3 everest79 | Posted 2007-04-29 02:20 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
netsh intreface show interface|find "Enabled"|find "Private"
|
|
| Floor4 feixiang9911 | Posted 2007-04-29 23:23 |
| 初级用户 Posts 16 Credits 34 | |
|
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? |
|
| Floor5 everest79 | Posted 2007-04-30 01:05 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
| Floor6 feixiang9911 | Posted 2007-05-01 02:29 |
| 初级用户 Posts 16 Credits 34 | |
|
Heheh, when will you be able to figure it out?
|
|
| Floor7 everest79 | Posted 2007-05-01 03:42 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
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 |
|
| Floor8 feixiang9911 | Posted 2007-05-01 06:10 |
| 初级用户 Posts 16 Credits 34 | |
|
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.
|
|
| Floor9 everest79 | Posted 2007-05-01 06:30 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
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.
|
|
| Floor10 flyinspace | Posted 2007-05-01 06:41 |
| 银牌会员 Posts 517 Credits 1,206 | |
|
I am like this code without conditional testing...
Just won't write it out. Afraid of being ashamed :) |
|
| Floor11 csx163 | Posted 2007-05-01 12:33 |
| 初级用户 Posts 45 Credits 97 | |
|
The network card without an Ethernet cable plugged in shows "Disconnected", and only the network card with normal connection shows "Connected".
|
|
| Floor12 feixiang9911 | Posted 2007-05-02 17:05 |
| 初级用户 Posts 16 Credits 34 | |
|
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 |
|
| Floor13 everest79 | Posted 2007-05-03 15:46 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
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.
|
|
| Floor14 chenall | Posted 2007-05-04 00:16 |
| 银牌会员 Posts 469 Credits 1,276 From 福建泉州 | |
|
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
|
|
| Floor15 qq43142691 | Posted 2007-05-04 07:04 |
| 中级用户 Posts 152 Credits 326 | |
|
@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 ] |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |