您好,我尝试创建脚本批处理文件以检查先前的口文件夹并删除该文件夹,当我通过双击运行时,它运行得很好并且可以删除文件夹,但是当我尝试按任务计划运行时,它显示运行完成,但是没什么,这是我的代码
@Echo Off & SetLocal
setlocal EnableDelayedExpansion
REM ////////////getpreviousmouth//////////////
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set
"dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set
"DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "previousdate=%YYYY%_%MM%_%DD%" & set "timestamp=%HH%%Min%%Sec%"
set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
For /F %%A In ('WMIc OS Get LocalDateTime') Do For %%B In (%%A) Do Set _=%%B
Set "YYYY=%_:~,4%" & Set "MM=%_:~4,2%" & Set "DD=%dt:~6,2%"
If %MM% Equ 01 (Set/A "YYYY-=1" & Set "MM=12") Else (Set/A "MM=1%MM%-1"
Call Set "MM=%%MM:~-2%%")
set "previousdate=%YYYY%-%MM%"
REM ////////////delete folder data in previousmouth//////////////
set pathdata=D:\Backup\InteractiveBackendDB_BK
CD %pathdata%
for /D %%A IN (%previousdate%"*") DO (
set pathfolders=%%A
set pathfolder=!pathfolders:~0,-3!
if !pathfolder!==%previousdate% (
echo !pathdata!\!pathfolders!
rd /s /q !pathdata!\!pathfolders!
)
timeout 10
)