复制代码
- @ color fc
- @ cls
- @ title Usblog_Killer 1.0 by =亮子=
- @ echo.
- @ echo.
- @ setlocal
- @ echo 程序功能:
- @ echo 自动删除U盘使用记录(XP版)
- @ echo.
- @ echo 欢迎访问亮子空间http://user.qzone.qq.com/378797716
- @ echo.
- @ echo 按任意键继续.....
- @ pause > nul
- @ cls
- @ echo off
- ::初始化环境变量,假设权限符合且注册表项ControlSet002和ControlSet003存在
- :begin
- set testset=1
- set test001=1
- set test002=1
- set test003=1
- set ControlSet002=1
- set ControlSet003=1
- ::计数器清零
- set count=0
- ::第一部分:【权限检测】
- ::通过增加空子项test,检测权限并列出权限不够的子项
- :test_right
- echo 开始清理系统中U盘记录!
- ping 127.0.0.1 -n 2 > nul
- ::测试CurrentControlSet权限
- echo.
- echo.
- echo 正在测试各注册表项权限。。。
- ping 127.0.0.1 -n 2 > nul
- reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR\Test
- if errorlevel 1 (
- set testset=0
- echo.
- echo HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\子项权限不够!!
- set /a count+=1
- ) else (
- echo 权限设置正确!
- )
- ::测试ControlSet001权限
- reg add HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\Test
- if errorlevel 1 (
- set test001=0
- echo.
- echo HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\子项权限不够!!
- set /a count+=1
- ) else (
- echo 权限设置正确!
- )
- ::检测是否存在set002项,如果存在则开始测试Enum子项的权限
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002 > nul
- if errorlevel 1 (
- echo.
- echo ControlSet002不存在,正在跳过此项的权限检测
- set ControlSet002=0
- ) else (
- echo.
- echo ControlSet002子项存在!正在进行权限检测。。。
- reg add HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\USBSTOR\Test
- if errorlevel 1 (
- set test002=0
- echo.
- echo HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\子项权限不够!!
- set /a count+=1
- ) else (
- echo 权限设置正确!
- )
- )
- ::检测是否存在set003项,如果存在再测试Enum子项的权限
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003 > nul
- if errorlevel 1 (
- echo.
- echo ControlSet003不存在,正在跳过此项的权限检测
- set ControlSet003=0
- ) else (
- echo.
- echo ControlSet003子项存在!正在进行权限检测。。。
- reg add HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Enum\USBSTOR\Test
- if errorlevel 1 (
- set test003=0
- echo.
- echo HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\子项权限不够!!
- set /a count+=1
- ) else (
- echo 权限设置正确
- )
- )
- echo.
- echo 测试完毕!
- echo.
- ping 127.0.0.1 -n 2 > nul
- ::如果存在权限设置问题,将提示用户修改权限后再运行程序
- if %testset%==0 goto quit
- if %test001%==0 goto quit
- if %test002%==0 goto quit
- if %test003%==0 goto quit
- goto del_begin
- :quit
- echo 您有%count%处注册表项权限不够!
- echo.
- echo 请参照上面的提示将相关权限设置为"完全控制"再运行本程序!
- echo.
- echo 按任意键退出
- pause > nul
- color
- start readme.txt
- exit
- :del_begin
- cls
- echo.
- echo 注册表权限设置正确! 程序开始前建议对注册表进行备份!
- echo.
- :choose
- echo 1---^>备份相关注册表 2---^>不用备份,开始程序
- echo.
- set /p choose=请选择:
- if "%choose%"=="1" (
- echo 开始备份...
- ping 127.0.0.1 -n 1 > nul
- reg export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum set_enum.reg
- reg export HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum 001_enum.reg
- if %ControlSet002%==1 (
- reg export HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum 002_enum.reg
- )
- if %ControlSet003%==1 (
- reg export HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Enum 003_enum.reg
- )
- reg export HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses Classes.reg
- echo.
- echo 备份完毕!备份文件在本程序所在目录下,双击即可恢复注册表
- echo.
- echo 按任意键开始清除U盘记录
- pause > nul
- goto del_usbstor
- )
- if "%choose%"=="2" (
- echo.
- echo 开始清除U盘记录....
- ping 127.0.0.1 -n 2 > nul
- goto del_usbstor
- ) else (
- echo.
- echo 输入错误!请重新输入
- echo.
- goto choose
- )
复制代码
- ::第二部分 【清理注册表USBSTOR子项】
- ::开始删除各USBSTOR子项
- :del_usbstor
- cls
- echo.
- echo 开始删除各USBSTOR子项
- ping 127.0.0.1 -n 3 > nul
- ::开始删除CurrentControlSet\Enum\USBSTOR\项
- :del_setusbstor
- echo 正在删除CurrentControlSet\Enum\USBSTOR项。。。
- reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR\ > test.txt
- for /f "skip=1 tokens=6 delims=\" %%i in ( test.txt ) do (
- if not %%i==USBSTOR (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- )
- if exist test.txt del test.txt
- echo.
- echo ------------------本项删除完毕--------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- ::开始删除ControlSet001\Enum\USBSTOR项
- :del_001usbstor
- echo 正在删除ControlSet001\Enum\USBSTOR项。。。
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\ > test.txt
- for /f "skip=1 tokens=6 delims=\" %%i in ( test.txt ) do (
- if not %%i==USBSTOR (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- )
- if exist test.txt del test.txt
- echo.
- echo ------------------本项删除完毕--------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- ::判断是否存在ControlSet002
- :check_ControlSet002
- if %ControlSet002%==0 (
- echo.
- echo ControlSet002 不存在!跳过删除
- ping 127.0.0.1 -n 1 > nul
- goto check_ControlSet003
- )
- ::删除ControlSet002\Enum\USBSTOR项
- :del_002usbstor
- echo 正在删除ControlSet002\Enum\USBSTOR项。。。
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\USBSTOR\ > test.txt
- for /f "skip=1 tokens=6 delims=\" %%i in ( test.txt ) do (
- if not %%i==USBSTOR (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\USBSTOR\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- )
- if exist test.txt del test.txt
- echo.
- echo ------------------本项删除完毕----------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- ::开始判断是否存在ControlSet003
- :check_ControlSet003
- if %ControlSet003%==0 (
- echo.
- echo ControlSet003不存在,跳过删除
- goto end1
- )
- ::开始删除ControlSet003\Enum\USBSTOR
- echo 正在删除ControlSet003\Enum\USBSTOR项。。。
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Enum\USBSTOR > test.txt
- for /f "skip=1 tokens=6 delims=\" %%i in ( test.txt ) do (
- if not %%i==USBSTOR (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Enum\USBSTOR\%%i /f
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- )
- if exist test.txt del test.txt
- echo.
- echo ------------------本项删除完毕-------------------
- echo.
- ::USBSTOR各项删除完毕
- :end1
- ping 127.0.0.1 -n 1 > nul
- echo.
- echo ----------------删除USBSTOR完毕 !-------------------
- echo.
- echo 个别子项如果无法删除属于正常现象!
- echo.
- echo 按任意键准备删除USB子项的记录
- pause > nul
- ::第三部分 【清理注册表各个USB子项】
- cls
- ::删除各个USB项,忽略其中的ROOT_HUB和ROOT_HUB20子项
- :del_usb
- echo.
- echo 准备删除各USB项。。。
- echo.
- ping 127.0.0.1 -n 2 > nul
- :del_setusb
- echo 正在清除CurrentControlSet\Enum\USB项。。。
- reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB > test.txt
- for /f "skip=1 tokens=6 delims=\" %%i in ( test.txt ) do (
- if not %%i==ROOT_HUB (
- if not %%i==ROOT_HUB20 (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\%%i /f
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- )
- )
- if exist test.txt del test.txt
- echo.
- echo --------------------本项删除完毕--------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- :del_001usb
- echo 正在删除ControlSet001\Enum\USB。。。
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB > test.txt
- for /f "skip=1 tokens=6 delims=\" %%i in ( test.txt ) do (
- if not %%i==ROOT_HUB (
- if not %%i==ROOT_HUB20 (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB\%%i /f
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- )
- )
- if exist test.txt del test.txt
- echo.
- echo --------------------本项删除完毕----------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- ::判断删除002usb
- :del_002usb
- if %ControlSet002%==1 (
- echo 正在删除ControlSet002\Enum\USB。。。
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\USB > test.txt
- for /f "skip=1 tokens=6 delims=\" %%i in ( test.txt ) do (
- if not %%i==ROOT_HUB (
- if not %%i==ROOT_HUB20 (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\USB\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- )
- )
- if exist test.txt del test.txt
- echo.
- echo.
- echo --------------------本项删除完毕---------------------
- ping 127.0.0.1 -n 1 > nul
- )
- if %ControlSet002%==0 (
- echo.
- echo ControlSet002不存在,跳过删除。。。
- ping 127.0.0.1 -n 1 > nul
- )
- ::判断删除003usb
- :del_003usb
- if %ControlSet003%==1 (
- echo 正在删除ControlSet003\Enum\USB。。。
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Enum\USB > test.txt
- for /f "skip=1 tokens=6 delims=\" %%i in ( test.txt ) do (
- if not %%i==ROOT_HUB (
- if not %%i==ROOT_HUB20 (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Enum\USB\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- )
- )
- if exist test.txt del test.txt
- echo.
- echo --------------------本项删除完毕----------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- )
- if %ControlSet003%==0 (
- echo.
- echo ControlSet003不存在,跳过删除。。。
- ping 127.0.0.1 -n 1 > nul
- )
- :end2
- echo.
- echo -------------------删除各USB子项完毕-------------------
- echo.
- echo 个别子项如果出现无法删除的情况属于正常现象
- echo.
- echo 按任意键继续删除DeviceClasses子项的记录
- pause > nul
复制代码
- ::第四部分 【清理注册表DeviceClasses项中与U盘记录有关的子项】
- cls
- :del_DeviceClasses
- ::开始测试是否存在{a5d...}
- :check_a5d
- echo.
- echo 正在检测DeviceClasses\{a5d...}
- ping 127.0.0.1 -n 1 > nul
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{a5dcbf10-6530-11d2-901f-00c04fb951ed} > test.txt
- if errorlevel 1 (
- if exist test.txt del test.txt
- echo.
- echo DeviceClasses\{a5d...}不存在,跳过清除!
- ping 127.0.0.1 -n 1 > nul
- goto check_53f56307
- )
- ::开始测试{a5d...}是否存在usb字符
- FOR /F "skip=1 tokens=3 delims=#" %%i in ( test.txt ) do (
- if %%i==USB goto del_a5d
- )
- echo 不存在USB记录!继续检测下一项
- if exist test.txt del test.txt
- goto check_53f56307
- ::开始删除{a5d...}
- :del_a5d
- echo 开始删除{a5d...}
- for /f "skip=1 tokens=7 delims=\" %%i in ( test.txt ) do (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{a5dcbf10-6530-11d2-901f-00c04fb951ed}\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- if exist test.txt del test.txt
- echo.
- echo --------------------本项删除完毕---------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- :: 开始测试是否存在{53f56307...}
- :check_53f56307
- echo.
- echo 正在检测DeviceClasses\{53f56307...}
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f56307-b6bf-11d0-94f2-00a0c91efb8b} > test.txt
- if errorlevel 1 (
- if exist test.txt del test.txt
- echo.
- echo DeviceClasses\53f56307不存在,跳过清除!
- ping 127.0.0.1 -n 2 > nul
- goto check_53f56308
- )
- ::开始测试{53f56307...}是否存在usb字符
- FOR /F "skip=1 tokens=3 delims=#" %%i in (test.txt) do (
- if %%i==USBSTOR goto del_53f56307
- )
- echo.
- echo 不存在USB记录!继续检测下一项
- if exist test.txt del test.txt
- goto check_53f56308
- ::开始删除{53f56307...}
- :del_53f56307
- echo 开始删除{53f56307...}
- for /f "skip=1 tokens=7 delims=\" %%i in ( test.txt ) do (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f56307-b6bf-11d0-94f2-00a0c91efb8b}\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- if exist test.txt del test.txt
- echo.
- echo --------------------本项删除完毕----------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- ::开始测试是否存在53f56308
- :check_53f56308
- echo.
- echo 正在检测DeviceClasses\{53f56308...}
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f56308-b6bf-11d0-94f2-00a0c91efb8b} > test.txt
- if errorlevel 1 (
- if exist test.txt del test.txt
- echo.
- echo DeviceClasses\53f56308不存在,跳过清除!
- ping 127.0.0.1 -n 1 > nul
- goto check_53f5630a
- )
- ::开始测试{53f56308...}是否存在usb字符
- FOR /F " skip=1 tokens=3 delims=#" %%i in (test.txt) do (
- if %%i==USBSTOR goto del_53f56308
- )
- echo 不存在USB记录!继续检测下一项
- if exist test.txt del test.txt
- goto check_53f5630a
- ::开始删除{53f56308...}
- :del_53f56308
- echo 开始删除{53f56308...}
- for /f "skip=1 tokens=7 delims=\" %%i in ( test.txt ) do (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f56308-b6bf-11d0-94f2-00a0c91efb8b}\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- if exist test.txt del test.txt
- echo.
- echo --------------------本项删除完毕----------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- ::开始测试是否存在53f5630a
- :check_53f5630a
- echo.
- echo 正在检测DeviceClasses\{53f5630a...}
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f5630a-b6bf-11d0-94f2-00a0c91efb8b} > test.txt
- if errorlevel 1 (
- if exist test.txt del test.txt
- echo.
- echo DeviceClasses\53f5630a不存在,跳过清除!
- ping 127.0.0.1 -n 1 > nul
- goto check_53f5630d
- )
- ::开始测试{53f5630a...}是否存在usb字符
- FOR /F "skip=1 tokens=3 delims=#" %%i in (test.txt) do (
- if %%i==USBSTOR goto del_53f5630a
- )
- echo 不存在USB记录!继续检测下一项
- if exist test.txt del test.txt
- goto check_53f5630d
- ::开始删除{53f5630a...}
- :del_53f5630a
- echo 开始删除{53f5630a...}
- for /f "skip=1 tokens=7 delims=\" %%i in ( test.txt ) do (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f5630a-b6bf-11d0-94f2-00a0c91efb8b}\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- if exist test.txt del test.txt
- echo.
- echo --------------------本项删除完毕----------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
复制代码
- ::开始测试是否存在53f5630d
- :check_53f5630d
- echo.
- echo 正在检测DeviceClasses\{53f5630d...}
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b} > test.txt
- if errorlevel 1 (
- if exist test.txt del test.txt
- echo.
- echo DeviceClasses\53f5630d不存在,跳过清除!
- ping 127.0.0.1 -n 1 > nul
- goto check_53f5630e
- )
- ::开始测试{53f5630d...}是否存在usb字符
- FOR /F "skip=1 tokens=3 delims=#" %%i in (test.txt) do (
- if %%i==USBSTOR goto del_53f5630d
- )
- echo 不存在USB记录!继续检测下一项
- if exist test.txt del test.txt
- goto check_53f5630e
- ::开始删除{53f5630d...}
- :del_53f5630d
- echo 开始删除{53f5630d...}
- for /f "skip=1 tokens=7 delims=\" %%i in ( test.txt ) do (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- if exist test.txt del test.txt
- echo.
- echo --------------------本项删除完毕----------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- :check_53f5630e
- echo.
- echo 正在检测DeviceClasses\{53f5630e...}
- reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f5630e-b6bf-11d0-94f2-00a0c91efb8b} > test.txt
- if errorlevel 1 (
- if exist test.txt del test.txt
- echo.
- echo DeviceClasses\53f5630e不存在,跳过清除!
- ping 127.0.0.1 -n 1 > nul
- goto end3
- )
- ::开始测试{53f5630a...}是否存在usb字符
- FOR /F " skip=1 tokens=3 delims=# " %%i in ( test.txt ) do (
- if %%i==USBSTOR goto del_53f5630e
- )
- echo 不存在USB记录!继续检测下一项
- if exist test.txt del test.txt
- goto end3
- ::开始删除{53f5630e...}
- :del_53f5630e
- echo 开始删除{53f5630e...}
- for /f "skip=1 tokens=7 delims=\" %%i in ( test.txt ) do (
- reg delete HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{53f5630e-b6bf-11d0-94f2-00a0c91efb8b}\%%i /F
- if errorlevel 1 (
- echo.
- echo %%i子项无法删除
- echo.
- )
- )
- if exist test.txt del test.txt
- echo.
- echo --------------------本项删除完毕----------------------
- echo.
- ping 127.0.0.1 -n 1 > nul
- :end3
- echo.
- echo ---------------删除DeviceClasses完毕--------------
- echo.
- echo 个别子项如果出现无法删除的情况属于正常现象
- echo.
- echo 按任意键继续。。。
- pause > nul
- cls
- echo.
- echo.
- echo.
- echo **********************************************
- echo **************** U盘记录清除完毕 *************
- echo **********************************************
- echo.
- echo.
- echo 请使用“U盘记录检查工具”检测本机记录清除情况,亮子的空间里有提供下载!
- echo.
- echo.
- echo 感谢使用亮子编写的批处理脚本工具!按任意键退出!
- pause > nul
- Endlocal
- color
- exit
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |