2014年1月23日 星期四

批次處理禁用、啟用USB設備如此簡單

批次處理禁用、啟用USB設備如此簡單(可按標準分類)zz
之前大家都用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盤,不管你有NU盤統統一起刪除devcon.exe disable  USB\Class_06禁用數碼相機,包括數碼相機附帶的抽取式磁碟devcon.exe disable  USB\Class_03禁用USB滑鼠&鍵盤devcon.exe disable  USB\Class_ff禁用攝像頭,看你還臭美;-禁用&啟用USB設備就如此簡單:cool:相關工具DevCon.exe微軟命令列實用工具可替代裝置管理員相關連接:http://www.microsoft.com/whdc/device/input/HID_HWID.mspxhttp://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 "delims=*" %%b in ('reg query "%%a"^|find /i "Vid_"') do (
        for /f "tokens=3" %%c in ('reg query "%%b"^|find /i "CompatibleIDs"') do (
            for /f "tokens=1,* delims=REG_SZ " %%d in ('reg query "%%b"^|find /i "DeviceDesc"') do (
                for /f "delims=&" %%i in ('echo."%%c"^|find /i "Class"') do echo "%%~i"   設備名稱:%%e
))))
echo.&echo 若要查詢USB\Class_XX以下分類,請將第5for"delims=&"改成"delims="
pause
 

_________________________________________________________________________________________________________________________________________________
This e-mail, sent by AIC mail system, may contain privileged, confidential information.  Please do not copy,disclose, distribute or use this e-mail for any other purpose.  If you are not the intended recipient, please delete it and notify us immediately.  We greatly appreciate your cooperation.
Analog Integrations Corporation  
http://www.analog.com.tw    

沒有留言:

張貼留言