编写批处理的问题(骨灰级高手进)

来源:百度知道 编辑:UC知道 时间:2024/06/30 17:53:14
我想编写一个autorun.inf病毒的免疫批处理代码如下
@echo off
for %%i 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 @fsutil fsinfo drivetype %%i:>>%systemroot%\UPV.TXT
findstr /i "固定驱动器" %systemroot%\UPV.TXT
for /f "tokens=1" %%i in ('findstr /i "固定驱动器" %systemroot%\UPV.TXT') do @set yidong=%%i
if exist %yidong%\autorun.inf
(attrib %yidong%\autorun.inf -R -s -h
del /s /q %yidong%\autorun.inf)
MD %yidong%\autorun.inf
ATTRIB %yidong%\autorun.inf +S +H +R
DEL %systemroot%\UPV.TXT
CLS
REN 免疫成功!
PAUSE
但是在不存在autorun.inf的情况下测试成功,如果存在autorun.inf则无法删除这个文件
麻烦高手门帮帮忙(别告诉我哪些软件可以,这样的软件我这里有,我就是想自己编写一个)

回答者:k4me - 榜眼 十三级 8-28 01:02
---------------------
补充
-----------
如果要用%yitong%,需要处理延迟问题,这个例子里直接用%%i代就行
-----------
@echo off
DEL %systemroot%\UPV.TXT
for %%i 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 @fsutil fsinfo drivetype %%i:>>%systemroot%\UPV.TXT
REM'findstr /i "固定驱动器" %systemroot%\UPV.TXT
for /f "tokens=1" %%i in ('findstr /i "固定驱动器" %systemroot%\UPV.TXT') do (
rem @set yidong=%%i
@echo %%i
if exist %%i\autorun.inf (
attrib %%i\autorun.inf -R -s -h
del /s /q %%i\autorun.inf
rem 'MD %%i\autorun.inf
rem '替换为
type nul>%%i\autorun.inf
ATTRIB %%i\autorun.inf +S +H +R
)
)
REM'DEL %systemroot%\UPV.TXT
rem CLS
REM 免疫成功!
PAUSE

9494

看不懂谢谢

不会呀!