Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 要使用Bat文件删除文件吗_Batch File - Fatal编程技术网

Batch file 要使用Bat文件删除文件吗

Batch file 要使用Bat文件删除文件吗,batch-file,Batch File,我想使用bat文件自动删除每个星期天的临时文件。位置为C:/xxx/yyy/temp。 你能帮忙吗。提前谢谢 DEL /S "C:/xxx/yyy/temp/*" 将其放在.bat文件中,并使用windows任务计划程序在每个星期天执行此操作 请原谅,我的英语不是母语,批处理文件不能在设定的时间自动运行,这就是任务调度程序的作用。您可以使用gui进行设置,或者如果您确实希望使用批处理文件进行部署,您可以将其放入其中并运行: at 10:00am /every:monday "del /s /q

我想使用bat文件自动删除每个星期天的临时文件。位置为C:/xxx/yyy/temp。 你能帮忙吗。提前谢谢

DEL /S "C:/xxx/yyy/temp/*"
将其放在.bat文件中,并使用windows任务计划程序在每个星期天执行此操作


请原谅,我的英语不是母语,批处理文件不能在设定的时间自动运行,这就是任务调度程序的作用。您可以使用gui进行设置,或者如果您确实希望使用批处理文件进行部署,您可以将其放入其中并运行:

at 10:00am /every:monday "del /s /q C:\xxx\yyy\temp"

我把它作为一个批处理文件,唯一的问题是它每天都会这样做。你需要找到一种方法,让它只在周日运行,或者让它每天运行

@echo off
:no
for /f "tokens=1,2,3,4 delims=:,. " %%i in ("%time%") do (
set hr=%%i
set mn=%%j
set sc=%%k
)
cls
echo %hr%
echo %mn%
echo %sc%
:Test1
IF %hr% == 10 goto Test2
timeout /t 30>nul
goto no
:Test2
IF %mn% == 00 goto yes
timeout /t 30>nul
goto no
:yes
DEL /S "C:/xxx/yyy/temp/*"
timeout /t 61>nul
goto no

在Windows.Yeah的更高版本中,
at
命令已替换为
schtasks
。非常感谢。它需要任务调度器来自动化任务。但是批处理编程的主要目标是使任务自动化和维护日志文件。您可以使用批处理创建计划任务。请参见
schtasks/create/?
如果您是第一次这样做的话,要找到正确的语法并不容易,但确实值得花一些时间来了解。