|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
   『楼 主』:
[分享]禁用&启用USB设备原来如此简单(可按标准分类)
使用 LLM 解释/回答一下
之前大家都用devcon find获取硬件ID(Hardware ID)通过for+find筛选来禁用或启用设备,但其名称不固定也没规律所以任何代码都不具有相对的通用性,我也一直以来因USB设备标准所困惑,本着不达目的誓不罢休的精神,开始寻求USB设备在Windows中的规律及USB设备标准,打开注册表编辑器开始从硬件相关的键值入手以寻找它们的相似之处及规律,最后定位到HKLM\SYSTEM\CurrentControlSet\Enum\USB,一一对比发现USB\Class_XX&SubClass_XX其有一定的规律,于是请出google高手相助,关键词CompatibleIDs在微软网站看到一点相关标准(微软标准并不是全部的标准),呵呵看来有希望了^_^,继续关键词USB Class,哈哈OK了!! www.usb.org 够标准了吧!好了闲话不多,开始分享我的劳动成果;-)
各设备分类标准
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
英文不好以上不作翻译了
禁用某设备方法devcon.exe disable USB\Class_XX
启用某设备方法devcon.exe enable USB\Class_XX (其中XX就是上面绿色部分序号)
例:
devcon.exe disable USB\Class_08
禁用U盘,即删除U盘,不管你有N个U盘统统一起删除
devcon.exe disable USB\Class_06
禁用数码相机,包括数码相机附带的可移动磁盘
devcon.exe disable USB\Class_03
禁用USB鼠标&键盘
devcon.exe disable USB\Class_ff
禁用摄像头,看你还臭美;-)
禁用&启用USB设备就如此简单 <img src="images/smilies/face-cool.png" align="absmiddle" border="0">
相关工具 DevCon.exe 微软命令行实用工具可替代设备管理器
相关连接:
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
最后也希望大家一起收集其他 USB\Class_XX 序号(跟贴)
查询已知或曾安装过的设备USB\Class_XX 序号批处理代码见下
@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"<img src="images/smilies/face-wink.png" align="absmiddle" border="0"> do echo "%%j" 设备名称:%%c
))))
echo.&echo 若要查询USB\Class_XX以下分类,请将第5个for的"delims=&"改成"delims=*"
pause
借助DevCon纯脚本备份驱动,兼容驱动精灵(2008-01-17)
Last edited by fastslz on 2009-9-13 at 05:19 ]
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 :cool:
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 ]
此帖被 +33 点积分 点击查看详情 评分人:【 zh159 】 | 分数: +10 | 时间:2008-1-15 02:05 | 评分人:【 huahua0919 】 | 分数: +4 | 时间:2008-1-15 09:54 | 评分人:【 zts59 】 | 分数: +4 | 时间:2008-1-16 21:16 | 评分人:【 everest79 】 | 分数: +15 | 时间:2008-3-2 11:43 |
|
|

第一高手 第二高手
我的小站
 |
|
2008-1-14 23:10 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
devcon.exe disable USB\Class_03
禁用USB鼠标&键盘
这个在某些地方好用啊^_^
devcon.exe disable USB\Class_03
Disable USB mice & keyboards
This works well in some places ^_^
|

 |
|
2008-1-15 02:05 |
|
|
voiL
中级用户
  
积分 384
发帖 189
注册 2005-10-19
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
还是fastslz厉害,这资料我也找好久了,可惜都找不全..
Still, fastslz is powerful. I've been looking for this material for a long time too, but unfortunately I couldn't find it all..
|
|
2008-1-16 11:34 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
本本上把 一些设备认为是 U 盘
The notebook considers some devices as USB flash drives.
|
|
2008-1-16 11:51 |
|
|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Originally posted by vkill at 2008-1-16 11:51:
本本上把 一些设备认为是 U 盘
估计某些本本把设备接的主板USB扩展接口上吧
那你再看看SubClass_XX规律,我这里只有USB鼠标也测试不出SubClass_XX,如果USB鼠标键盘都是USB\Class_03那SubClass_XX序号可能不一样的,有的朋友看一下,1楼代码"delims=&"改成"delims="就可以看到了
哎~微软reg query的BUG真够恶心的
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.
|

第一高手 第二高手
我的小站
 |
|
2008-1-16 12:58 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
学习代码,更学习精神。
Learning code, but also learning spirit.
|
|
2008-1-16 13:38 |
|
|
zts59
中级用户
  
积分 387
发帖 104
注册 2004-11-19
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
哇,不错,很全了哇,谢谢
Wow, it's great, very comprehensive. Thanks
|
|
2008-1-16 14:11 |
|
|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
在华硕主版上没用, VIMICRO USB PC Camera (ZC0301PLH)
禁用成功, 但是还是能用摄像头
It doesn't work on ASUS motherboard, VIMICRO USB PC Camera (ZC0301PLH). Disabled successfully, but the camera can still be used.
|
|
2008-1-16 16:17 |
|
|
regvip2008
初级用户
 
积分 187
发帖 87
注册 2007-10-23
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
"devcon"这个命令还有如此强大的功能呀?
呵呵,多谢“fastslz”提供!
如此好帖,不得不顶!
"devcon" command has such powerful functions?
Hehe, thanks "fastslz" for providing!
Such a good post, can't help but top it!
|
|
2008-1-16 17:49 |
|
|
enjoyer
中级用户
   部落守望者
积分 351
发帖 140
注册 2006-6-19
状态 离线
|
『第 10 楼』:
好贴要顶
使用 LLM 解释/回答一下
想系统地学学USB方面的东西,尤其是操作系统对USB设备的管理,
I want to systematically learn about USB - related things, especially the management of USB devices by the operating system.
|

一切从底层开始 |
|
2008-1-16 22:56 |
|
|
icm
新手上路

积分 12
发帖 6
注册 2006-10-23
状态 离线
|
|
2008-1-17 14:04 |
|
|
zts59
中级用户
  
积分 387
发帖 104
注册 2004-11-19
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
请问楼主,DEVCON是修改什么来达到禁用设备的?
为什么用DEVCON禁用设备后:devcon.exe disable USB\Class_08
重启系统,又可以用了,晕
如何不用DEVCON来禁用设备呢? 比如修改注册表之类的.
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.
|
|
2008-1-24 20:59 |
|
|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
除了DEVCON禁用设备,还有wmic,注册表更复杂(还不一定成功)
当然你可以从注册表中彻底禁用USB设备
关键字 “彻底禁用USB设备” google
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
|

第一高手 第二高手
我的小站
 |
|
2008-1-24 22:28 |
|
|
rot04021
新手上路

积分 6
发帖 5
注册 2006-10-22
状态 离线
|
|
2008-1-25 01:17 |
|
|
student007
新手上路

积分 10
发帖 5
注册 2008-1-13
状态 离线
|
|
2008-1-25 23:39 |
|