Board logo

标题: 写了个删除全盘AUTORUN的P处理,出了点小问题 [打印本页]

作者: junyee     时间: 2009-11-28 12:34    标题: 写了个删除全盘AUTORUN的P处理,出了点小问题

如下---- for %%a 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 ( for /f "tokens=1,2* delims==" %%i in (%%a:\autorun.inf) do ( del /q /a-d %%a:\%%j ) for /f "delims=" %%x in ('dir /ad /b %%a:\') do ( if exist %%x.exe ( attrib -s -h %%a:\%%x del %%x.exe /f /q ) ) del /f /q /a-d %%a:\autorun.inf ) echo Clean Over! PAUSE ----------------------------------------------------- 测试:在D盘建立一个autorun.ini 其中包含open=1.exe 另在D盘建立一个文件夹"1",再建立一个"1.exe". 其中文件夹1为系统+隐藏属性. 运行该P处理后,autorun.inf和1.exe都被删除,但是文件夹1的隐藏属性没有被去掉. 哪位来指点一下,是哪里出问题了>>???

作者: honcho     时间: 2009-11-28 14:00
del /q /a-d %%a:\%%j =》已经删除1.exe if exist %%x.exe =》1.exe不存在,所以文件夹1未被 -s -h [ Last edited by honcho on 2009-11-28 at 17:09 ]

作者: ZJHJ     时间: 2009-11-29 10:12
增加 rd /s /q "%%i" 另 有可能你的代码会误删除*.exe,应该是检测 open=什么? 因为 not open=autorun.exe

作者: junyee     时间: 2009-11-29 18:54
Originally posted by honcho at 2009-11-28 14:00: del /q /a-d %%a:\%%j =》已经删除1.exe if exist %%x.exe =》1.exe不存在,所以文件夹1未被 -s -h [ Last edited by honcho on 2009-11-28 at 17:09 ]
啊,大哥,眼真尖呀。 明白了,谢谢。把3-5行和6-11行换个位置就行了。
Originally posted by ZJHJ at 2009-11-29 10:12: 增加 rd /s /q "%%i" 另 有可能你的代码会误删除*.exe,应该是检测 open=什么? 因为 not open=autorun.exe
会误删除吗??我这里是只要autorun.inf中"="号之后的*.exe我就删除,不管是不是正常的,谁叫你取和autorun.inf 里相同的文件名啊。。 检测 open= ,是要以“open=”为分隔符吧,这对我来说要实现有点难度。(以前看过某高手回答的:先把autorun.inf中的"open="替换成一个不常用的字符,再来提取。) 谢谢大家帮助。谢谢了