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-29 12:51
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Share] Disabling & Enabling USB Devices Is So Simple (Classifiable by Standards) View 6,848 Replies 35
Original Poster Posted 2008-01-14 23:10 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Previously, everyone used devcon find to obtain the Hardware ID and filtered by for + find to disable or enable devices. However, their names are not fixed and have no pattern, so any code is not relatively universal. I have always been puzzled by the USB device standard. With the spirit of not giving up until the goal is achieved, I started to seek the rules of USB devices in Windows and the USB device standard. I opened the Registry Editor and started from the hardware-related key values to find their similarities and rules. Finally, I located HKLM\SYSTEM\CurrentControlSet\Enum\USB. By comparing one by one, I found that USB\Class_XX&SubClass_XX has a certain pattern. Then I invited Google experts for help. I saw some relevant standards on the Microsoft website with the keyword CompatibleIDs (Microsoft standards are not all standards). Hehe, it seems there is hope! ^_^ Continue with the keyword USB Class, haha OK!!www.usb.org It's standard enough! Well, enough small talk, start sharing my hard work; -)

Classification standards of each device
00 Use class information in the Interface Descriptors
01 Audio
02 Communications and CDC Control
03 HID (Human Interface Device)
05 Physical
06 Image
07 Printer
08 Mass Storage
09 Hub
0A CDC-Data
0B Smart Card
0D Content Security
0E Video
0F Personal Healthcare
DC Diagnostic Device
E0 Wireless Controller
EF Miscellaneous
FE Application Specific
FF Vendor Specific

Not translating the above due to poor English

Method to disable a device: devcon.exe disable USB\Class_XX
Method to enable a device: devcon.exe enable USB\Class_XX
(where XX is the serial number in the green part above)

Example:
devcon.exe disable USB\Class_08
Disable USB flash drives, that is, delete USB flash drives, no matter how many USB flash drives you have, all delete together
devcon.exe disable USB\Class_06
Disable digital cameras, including the removable disks attached to digital cameras
devcon.exe disable USB\Class_03
Disable USB mice & keyboards
devcon.exe disable USB\Class_ff
Disable cameras, see you still show off; -)
Disabling & enabling USB devices is so simple

Related tools DevCon.exe Microsoft command-line utility can replace Device Manager
Related links:
http://www.microsoft.com/whdc/device/input/HID_HWID.mspx
http://www.usb.org/developers/defined_class/
http://www.cn-dos.net/forum/viewthread.php?tid=35139&fpage=1

Finally, I also hope everyone can collect other USB\Class_XX serial numbers (post replies)
Batch code to query the USB\Class_XX serial number of known or previously installed devices is as follows


@echo off
for /f "delims=*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Enum\USB"^|find /i "Vid_"' do (
for /f "skip=4 delims=" %%b in ('reg query "%%a"' do (
for /f "skip=4 tokens=3" %%i in ('reg query "%%b" /v CompatibleIDs' do (
for /f "skip=4 tokens=1,2,*" %%a in ('reg query "%%b" /v DeviceDesc' do (
for /f "delims=&" %%j in ("%%i" do echo "%%j" Device name: %%c
))))
echo.&echo If you want to query USB\Class_XX classification below, change the "delims=&" of the 5th for to "delims=*"
pause


Back up drivers using pure DevCon script, compatible with Driver Genius (2008-01-17)

[ Last edited by fastslz on 2009-9-13 at 05:19 ]
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
zh159 +10 2008-01-15 02:05
huahua0919 +4 2008-01-15 09:54
zts59 +4 2008-01-16 21:16
everest79 +15 2008-03-02 11:43
第一高手 第二高手

Floor 2 Posted 2008-01-15 02:05 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
devcon.exe disable USB\Class_03
Disable USB mice & keyboards


This works well in some places ^_^
Floor 3 Posted 2008-01-16 11:34 ·  中国 广东 肇庆 四会市 电信
中级用户
★★
Credits 384
Posts 189
Joined 2005-10-19 13:12
20-year member
UID 43709
Gender Male
Status Offline
Still, fastslz is powerful. I've been looking for this material for a long time too, but unfortunately I couldn't find it all..
Floor 4 Posted 2008-01-16 11:51 ·  中国 甘肃 兰州 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
The notebook considers some devices as USB flash drives.
Floor 5 Posted 2008-01-16 12:58 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Originally posted by vkill at 2008-1-16 11:51:
Some devices on the laptop are considered as USB drives.

It is estimated that some laptops connect the device to the USB expansion port of the motherboard.
Then you can take a look at the SubClass_XX pattern. Here, only the USB mouse cannot test SubClass_XX. If both the USB mouse and keyboard are USB\Class_03, the SubClass_XX serial number may be different. Some friends can take a look. Change "delims=&" in the code on the first floor to "delims=" to see it.
Hey~ The bug of Microsoft reg query is really disgusting.
第一高手 第二高手

Floor 6 Posted 2008-01-16 13:38 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Learning code, but also learning spirit.
Floor 7 Posted 2008-01-16 14:11 ·  中国 广东 东莞 电信
中级用户
★★
Credits 387
Posts 104
Joined 2004-11-19 00:00
21-year member
UID 33813
Gender Male
Status Offline
Wow, it's great, very comprehensive. Thanks
Floor 8 Posted 2008-01-16 16:17 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 452
Posts 202
Joined 2006-12-21 13:46
19-year member
UID 74161
Gender Female
Status Offline
It doesn't work on ASUS motherboard, VIMICRO USB PC Camera (ZC0301PLH). Disabled successfully, but the camera can still be used.
Floor 9 Posted 2008-01-16 17:49 ·  中国 湖南 长沙 电信
初级用户
★★
Credits 187
Posts 87
Joined 2007-10-23 16:04
18-year member
UID 100558
Gender Male
Status Offline
"devcon" command has such powerful functions?
Hehe, thanks "fastslz" for providing!
Such a good post, can't help but top it!
Floor 10 Posted 2008-01-16 22:56 ·  中国 广东 深圳 南山区 电信
中级用户
★★
部落守望者
Credits 351
Posts 140
Joined 2006-06-19 17:11
20-year member
UID 57261
Gender Male
Status Offline
I want to systematically learn about USB - related things, especially the management of USB devices by the operating system.
一切从底层开始
Floor 11 Posted 2008-01-17 14:04 ·  中国 黑龙江 哈尔滨 联通
新手上路
Credits 12
Posts 6
Joined 2006-10-23 21:14
19-year member
UID 67907
Gender Male
Status Offline
Floor 12 Posted 2008-01-24 20:59 ·  中国 广东 东莞 电信
中级用户
★★
Credits 387
Posts 104
Joined 2004-11-19 00:00
21-year member
UID 33813
Gender Male
Status Offline
May I ask the original poster, what is DEVCON modifying to achieve disabling a device?

Why after using DEVCON to disable a device: devcon.exe disable USB\Class_08

After restarting the system, it can be used again. Oh my

How to disable a device without using DEVCON? For example, modifying the registry and so on.
Floor 13 Posted 2008-01-24 22:28 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
In addition to DEVCON to disable devices, there is also wmic, and the registry is more complicated (and not necessarily successful)
Of course, you can completely disable USB devices from the registry
Keyword "completely disable USB devices" google
第一高手 第二高手

Floor 14 Posted 2008-01-25 01:17 ·  中国 香港 电讯盈科有限公司
新手上路
Credits 6
Posts 5
Joined 2006-10-22 05:16
19-year member
UID 67646
Gender Male
Status Offline
Floor 15 Posted 2008-01-25 23:39 ·  中国 广东 珠海 联通
新手上路
Credits 10
Posts 5
Joined 2008-01-13 10:00
18-year member
UID 108462
Gender Male
Status Offline
Thanks, share.
Learned
Forum Jump: