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-06-24 13:16
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Resolved and Updated] Disable the local area connection network card in batch and then re-enable the connection View 10,992 Replies 15
Original Poster Posted 2006-07-18 12:22 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
19-year member
UID 57801
Gender Male
Status Offline
Asking all you experts:

I want to disable the local connection in the batch script and then enable it immediately, (that is, the process of right-clicking the "Local Connection" icon in the system tray on the Windows interface and selecting "Disable", then right-clicking "Network Neighborhood" and selecting "Local Connection" and clicking it to select "Enable"). But which command can achieve such a function?

I found netsh, but the syntax still can't be implemented... I hope someone can give me a pointer...

===========
@echo off
netsh interface set interface "Local Area Connection" "disabled"
netsh interface set interface "Local Area Connection" "enabled"
exit
=============
:(

[ Last edited by flying008 on 2006-7-22 at 08:07 ]
Floor 2 Posted 2006-07-20 09:10 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
19-year member
UID 57801
Gender Male
Status Offline
I searched a lot of similar posts online, and the answers were nothing but the above commands. But actually, NETSH can't solve this problem; otherwise, there wouldn't be DEVCON. After spending N hours of exploration , I finally solved this problem. However, I still need to rely on a small thing developed by Microsoft, DEVCON. I will write out the detailed process and usage later, to be continued...

If you run the devcon help command, a list of commands and description information will appear. The devcon help command can provide detailed help about any command. Using some of these commands, you can specify a remote target computer.

[ Last edited by flying008 on 2006-7-21 at 13:52 ]
Floor 3 Posted 2006-07-20 13:14 ·  中国 广东 深圳 盈联宽带
高级用户
★★★
Credits 972
Posts 420
Joined 2004-05-16 00:00
22-year member
UID 24467
Gender Male
Status Offline
Hurry up
netsh is really not easy to use, picking the name of the network connection, not universal
平生进退如飙风
Floor 4 Posted 2006-07-21 13:42 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
19-year member
UID 57801
Gender Male
Status Offline
Here comes……
Preface: Because I need to disable and enable the network card under batch processing, I specially found a lot of such posts. There are also many people on the Internet who write statements like netsh interface set interface "Local Area Connection" "disabled" to say that it can be disabled, but in fact---------using netsh cannot successfully disable the network card. At least I have tried for N hours and it is not successful. Fortunately, I found--------devcon.exe, this small thing developed by Microsoft. Although it is not very intelligent, it solves the problem to a certain extent. Now let's talk about the outline of it:
The DevCon utility is a command-line utility that can replace Device Manager. With DevCon, you can enable, disable, restart, update, delete, and query a single device or a group of devices. DevCon also provides information related to driver developers that cannot be seen in Device Manager.

DevCon can be used for Microsoft Windows 2000, Windows XP, and Windows Server 2003, but it cannot be used for Windows 95, Windows 98, or Windows Millennium Edition.
General usage: (Introduce several common commands and grammars)
1. devcon find
devcon find *
devcon find pci\*
2. devcon disable *msloop
3. devcon enable '*MSLOOP
is really an asterisk, not a wildcard]
4. devcon remove @usb\*
Delete all USB devices. The deleted devices will display their deletion status when listed

Because an example will be talked about below, so first talk about what the hardware ID is, to be honest, it is to let everyone know how to find it. Please see:
find pci\* The following is part of what is found:
PCI\VEN_10EC&DEV_8139&SUBSYS_813910EC&REV_10\3&13C0B0C5&0&58: Realtek RTL8139 Family PCI Fast Ethernet NIC
PCI\VEN_1106&DEV_0571&SUBSYS_18271019&REV_06\3&13C0B0C5&0&89: VIA Bus Master IDE Controller
PCI\VEN_1106&DEV_3038&SUBSYS_18271019&REV_80\3&13C0B0C5&0&80: VIA Rev 5 or later USB Universal Host Controller
The part before ":" in these lines is the hardware ID, and the part after is the device name.
I am going to disable the network card, please see carefully:
devcon disable *DEV_8139*
I am going to enable it, do the same: devcon enable *DEV_8139*
If you specify -r and need to restart, then after processing all devices, it will restart without any warning messages. Other things will not be said much. If you like to use it, go and download a compressed package to use on your own computer. Some people may think that if it has more powerful functions, please rely on yourself... Believe in yourself!
There are 2 folders in the compressed package, one for 32-bit use and one for 64-bit use,
The DevCon.exe file contains the following files:
File Description
I386\DevCon.exe Binary file of the 32-bit DevCon tool. This file does not function fully on 64-bit Windows.
Ia64\DevCon.exe Binary file of the 64-bit DevCon tool.
Download address:
http://download.microsoft.com/download/1/1/f/11f7dd10-272d-4cd2-896f-9ce67f3e0240/devcon.exe

[ Last edited by flying008 on 2006-7-21 at 13:49 ]
Floor 5 Posted 2006-11-30 07:40 ·  中国 湖南 怀化 电信
初级用户
Credits 170
Posts 25
Joined 2004-11-11 00:00
21-year member
UID 33534
Gender Male
Status Offline
Thanks a lot, flying008
Floor 6 Posted 2006-11-30 08:03 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
netsh interface set interface "Local Area Connection" "disabled"确实可以 use, I have used it, and it succeeds every time.
Among them, "Local Area Connection" is the name of the connected connection in the Control Panel - Network Connections. If you have changed the name, or it is not the network on the default Local Area Connection but the network on the connection you created yourself, it will not work. You need to change the word "Local Area Connection" to the name of the connection you are using.
Floor 7 Posted 2006-11-30 10:24 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

netsh is really not easy to use, picking the name of the network connection, not universal

That's because your batch processing is not good. Can you get the connection name by reading the registry?

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 8 Posted 2006-12-09 04:52 ·  中国 河南 郑州 电信
中级用户
★★
Credits 439
Posts 170
Joined 2006-01-09 20:29
20-year member
UID 48707
Status Offline
```batch
for /f "usebackq tokens=3 delims= " %%i in (`netsh interface show interface^|find "专用"`) do (
set a=%%i
if #%%i neq #本地连接 netsh interface set interface name=%%i newname=本地连接
)
pause
```
Modify the name of the local connection
bat c c++
Floor 9 Posted 2007-03-17 04:50 ·  中国 北京 海淀区 联通
新手上路
Credits 6
Posts 3
Joined 2007-02-26 04:51
19-year member
UID 80192
Gender Male
Status Offline
Strongly protest!!!!!
That thing doesn't work!!!!!
PCI\VEN_1022&DEV_1100&SUBSYS_00000000&REV_00\3&267A616A&0&C0: PCI standard host
CPU bridge
PCI\VEN_1022&DEV_1101&SUBSYS_00000000&REV_00\3&267A616A&0&C1: PCI standard host
CPU bridge
PCI\VEN_1022&DEV_1102&SUBSYS_00000000&REV_00\3&267A616A&0&C2: PCI standard host
CPU bridge
PCI\VEN_1022&DEV_1103&SUBSYS_00000000&REV_00\3&267A616A&0&C3: PCI standard host
CPU bridge
PCI\VEN_10DE&DEV_0242&SUBSYS_02421849&REV_A2\3&267A616A&0&28: NVIDIA GeForce 610
0
PCI\VEN_10DE&DEV_0261&SUBSYS_00000000&REV_A2\3&267A616A&0&50: PCI standard ISA b
ridge
PCI\VEN_10DE&DEV_0264&SUBSYS_02641849&REV_A2\3&267A616A&0&51: NVIDIA nForce PCI
System Management
PCI\VEN_10DE&DEV_0265&SUBSYS_02651849&REV_A1\3&267A616A&0&68: PCI\VEN_10DE&DEV_0
269&SUBSYS_02691849&REV_A1\3&267A616A&0&A0: NVIDIA Network Bus Enumerator
PCI\VEN_10DE&DEV_026B&SUBSYS_08501849&REV_A2\3&267A616A&0&82: Realtek AC'97 Audi
o
PCI\VEN_10DE&DEV_026D&SUBSYS_026D1849&REV_A2\3&267A616A&0&58: Standard OpenHCD U
SB Host Controller
PCI\VEN_10DE&DEV_026E&SUBSYS_026E1849&REV_A2\3&267A616A&0&59: Standard Enhanced
PCI to USB Host Controller
PCI\VEN_10DE&DEV_026F&SUBSYS_00000000&REV_A2\3&267A616A&0&80: PCI standard PCI-t
o-PCI bridge
PCI\VEN_10DE&DEV_0270&SUBSYS_02701849&REV_A2\3&267A616A&0&48: nForce Memory Cont
roller
PCI\VEN_10DE&DEV_027E&SUBSYS_027E1849&REV_A2\3&267A616A&0&07: nForce Memory Cont
roller
PCI\VEN_10DE&DEV_027F&SUBSYS_027F1849&REV_A2\3&267A616A&0&06: nForce Memory Cont
roller
PCI\VEN_10DE&DEV_02F1&SUBSYS_02F11849&REV_A2\3&267A616A&0&00: PCI standard RAM C
ontroller
PCI\VEN_10DE&DEV_02F8&SUBSYS_02F81849&REV_A2\3&267A616A&0&03: nForce Memory Cont
roller
PCI\VEN_10DE&DEV_02F9&SUBSYS_02F91849&REV_A2\3&267A616A&0&04: nForce Memory Cont
roller
PCI\VEN_10DE&DEV_02FB&SUBSYS_00000000&REV_A1\3&267A616A&0&20: PCI standard PCI-t
o-PCI bridge
PCI\VEN_10DE&DEV_02FC&SUBSYS_00000000&REV_A1\3&267A616A&0&10: PCI standard PCI-t
o-PCI bridge
PCI\VEN_10DE&DEV_02FD&SUBSYS_00000000&REV_A1\3&267A616A&0&18: PCI standard PCI-t
o-PCI bridge
PCI\VEN_10DE&DEV_02FE&SUBSYS_02FE1849&REV_A2\3&267A616A&0&02: nForce Memory Cont
roller
PCI\VEN_10DE&DEV_02FF&SUBSYS_02FF1849&REV_A2\3&267A616A&0&05: nForce Memory Cont
roller
24 matching device(s) found.
Who can tell me which one is the network card
Floor 10 Posted 2007-03-17 05:13 ·  中国 浙江 宁波 电信
中级用户
★★
Credits 385
Posts 156
Joined 2007-01-19 02:32
19-year member
UID 76955
Gender Male
Status Offline
Originally posted by electronixtar at 2006-11-29 09:24 PM:

That's because your batch processing is not working. Can you get the connection name by reading the registry?

Can you explain how to read the registry?
Floor 11 Posted 2007-03-17 06:08 ·  中国 浙江 电信
中级用户
★★
Credits 385
Posts 156
Joined 2007-01-19 02:32
19-year member
UID 76955
Gender Male
Status Offline
The landlord can try this command to see if it meets your requirements

rasphone -h VPN

Can disconnect the VPN dial-up connection
Floor 12 Posted 2007-03-17 15:42 ·  中国 广东 广州 黄埔区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
The command of the landlord can close the public network interface WAN, but cannot be used to close the private network interface LAN. Because the private network interface is managed locally by default whether it is disabled or not, so the admin state will not have any effect at all
Floor 13 Posted 2007-03-25 04:29 ·  中国 湖北 随州 电信
初级用户
Credits 29
Posts 16
Joined 2007-03-23 03:14
19-year member
UID 82610
Gender Male
Status Offline
The method introduced by flying008 I just verified, it's very effective, thank you for the guidance.
Floor 14 Posted 2007-11-10 14:24 ·  中国 安徽 马鞍山 电信
中级用户
★★
拟谷盗
Credits 312
Posts 108
Joined 2007-01-21 11:36
19-year member
UID 77238
Gender Male
Status Offline
netsh interface set interface "Local Area Connection" "disabled"
netsh interface set interface "Local Area Connection" "enabled"

Only for non-LAN
Floor 15 Posted 2007-12-28 14:41 ·  中国 广东 广州 天河区 电信
初级用户
★★
Credits 71
Posts 59
Joined 2007-12-27 17:53
18-year member
UID 106966
Gender Male
Status Offline
It's quite useful.. just need to find the network card... I wonder if there's any way to find the network card...
Forum Jump: