中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-04 00:03
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 发个自己写的删除U盘自动运行批处理 查看 1,019 回复 5
楼 主 发个自己写的删除U盘自动运行批处理 发表于 2007-04-06 06:02 ·  中国 湖北 武汉 教育网
初级用户
积分 118
发帖 34
注册 2006-01-10 09:01
20年会员
UID 48727
状态 离线
代码如下:


@echo off
:: code by bg
set virus=
for %%f in (C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do (
if exist %%f:\nul (
if exist %%f:\autorun.inf (
dir %%f:|find "0 可用字节">nul
if errorlevel 1 (
attrib -s -h %%f:\autorun.inf>nul
for /f "tokens=2 delims==," %%n in (%%f:\autorun.inf) do (
if exist %%f:\%%n (
tasklist|find "%%n">nul
if not errorlevel 1 (
echo 恭喜你,机子中毒了
echo 现在求老天保佑你吧。
taskkill /im /f /t %%n
)
attrib -s -h %%f:\%%n
del %%f:\%%n /f/q
echo 删除病毒文件--%%f:\%%n
set virus=1
)
)
del %%f:\autorun.inf /f/q
)
)
)
)
)
)
if "%virus%"=="1" goto norun
exit

:norun
shutdown -l
2 发表于 2007-04-06 06:05 ·  中国 湖北 武汉 教育网
初级用户
积分 118
发帖 34
注册 2006-01-10 09:01
20年会员
UID 48727
状态 离线
该批处理可以去除硬盘和U盘上的自动运行文件,但是一旦你中招了,那就没有办法了,还是要小心。
3 发表于 2007-04-06 08:47 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
积分 3,687
发帖 1,467
注册 2005-08-08 12:00
20年会员
UID 44210
状态 离线
我的U盘autorun.inf 内容是:
[AutoRun]
icon=*.ico

也被删除了
4 发表于 2007-04-06 09:08 ·  中国 湖北 武汉 教育网
初级用户
积分 118
发帖 34
注册 2006-01-10 09:01
20年会员
UID 48727
状态 离线
我没有考虑那么多,等我改下,加个判断的再发上来。
5 发表于 2007-04-06 10:02 ·  中国 浙江 杭州 电信
银牌会员
★★★
积分 1,928
发帖 931
注册 2007-01-06 11:46
19年会员
UID 75624
性别 男
状态 离线
:-)。不错哦。学习了。
6 发表于 2007-04-06 10:08 ·  中国 湖北 武汉 教育网
初级用户
积分 118
发帖 34
注册 2006-01-10 09:01
20年会员
UID 48727
状态 离线
我改了,现在应该没有什么问题了。

@echo off
:: code by bg
set virus=
for %%f in (C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do (
if exist %%f:\nul (
if exist %%f:\autorun.inf (
dir %%f:|find "0 可用字节">nul
if errorlevel 1 (
attrib -s -h %%f:\autorun.inf>nul
for /f "tokens=1,2 delims==," %%a in (%%f:\autorun.inf) do (
if /i "%%a"=="OPEN" (
if exist %%f:\%%b (
tasklist|find "%%b">nul
if not errorlevel 1 (
echo 恭喜你,机子中毒了
echo 现在求老天保佑你吧。
taskkill /im /f /t %%b
)
del %%f:\autorun.inf /f/q
attrib -s -h %%f:\%%b
del %%f:\%%b /f/q
echo 删除病毒文件--%%f:\%%b
set virus=1
)
)
)
)
attrib +s +h %%f:\autorun.inf>nul
)
)
)
)
)
if "%virus%"=="1" goto norun
exit

:norun
pause
shutdown -l
论坛跳转: