自动删除U盘目录下的指定文件

来源:百度知道 编辑:UC知道 时间:2024/06/20 11:49:18
不打开磁盘的情况下,数秒后删除指定文件并间隔数秒对磁盘重复扫描一下。本人有相关代码,但需要有人完善,一下是相关代码:
@echo off
:1
for %%i in (J H) do (
if exist %%i: (
if not exist %%i:/identify.sys (
if exist %%i:/*.url (
del /f /s /q %%i:\*.url
)
)
if exist %%i:/identify.sys (
FOR /F "tokens=*" %%j in (%%i:/identify.sys) do (if %%j==administrator (goto end) else (if exist %%i:/*.url (
del /f /s /q %%i:\*.url
)))
)
)
)
@echo off & setlocal enableextensions enabledelayedexpansion
echo WScript.Sleep 10000 > %temp%\tmp$$$.vbs
cscript //nologo %temp%\tmp$$$.vbs
for %%f in (%temp%\tmp$$$.vbs) do if exist %%f del %%f
endlocal

以上代码本人设置为十秒钟,但是怎样才可写入进程,自动跟随windows启动,

编一个批处理文件,扩展名“.bat”用del命令即可如:
del /q /f .\autorun.inf

将比处理文件放在U盘根目录下,双击运行就能自动删除指定文件
如:autorun.inf