我有一个运行批处理文件的计划任务,尽管我可以看到它成功完成的结果,但根据任务计划程序,它每次都会失败并出现错误 0xff。
标题 归档
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 "minFiles=3"
set "_my_date=%YYYY%%MM%%DD%" & set "time=%HH%%Min%"
set "datetime=%YYYY%%MM%%DD%%HH%%Min%"
set "month=%MM%"
set "year=%YYYY%"
for /f "tokens=* delims=0" %%i in ("%month%") do set month=%%i
for /f "tokens=%month%" %%i in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set monthM=%%i
setlocal EnableDelayedExpansion
rar a -ep1 -r -y -t -rr -df E:\MSSQL_BackUP\MSSQL_BackUP_%datetime%.rar @filelist.txt
net use Z: \\ADMW10\1C_BackUp\
net use X: \\ARCDSP-ARCHIV\1CSysBackUP\
if not exist "Z:\%year%\" mkdir Z:\%year%\
if not exist "X:\%year%\" mkdir X:\%year%\
dir /b /a "Z:\%year%\*" | >nul findstr "^" && (echo Files and/or Folders exist) ||
(
echo No File or Folder found
echo Creating Folders
cd /d Z:\%year%\
MKDIR 1_Jan
MKDIR 2_Feb
MKDIR 3_Mar
MKDIR 4_Apr
MKDIR 5_May
MKDIR 6_Jun
MKDIR 7_Jul
MKDIR 8_Aug
MKDIR 9_Sep
MKDIR 10_Oct
MKDIR 11_Nov
MKDIR 12_Dec
)
dir /b /a "X:\%year%\*" | >nul findstr "^" && (echo Files and/or Folders exist) ||
(
echo No File or Folder found
echo Creating Folders
cd /d X:\%year%\
MKDIR 1_Jan
MKDIR 2_Feb
MKDIR 3_Mar
MKDIR 4_Apr
MKDIR 5_May
MKDIR 6_Jun
MKDIR 7_Jul
MKDIR 8_Aug
MKDIR 9_Sep
MKDIR 10_Oct
MKDIR 11_Nov
MKDIR 12_Dec
)
copy E:\MSSQL_BackUP\*.rar Z:\%year%\%month%_%monthM%
copy E:\MSSQL_BackUP\*.rar X:\%year%\%month%_%monthM%
for /F "delims=" %%I in ('dir "E:\1C_BackUp\*" /A-D-H /B /O-D /TW 2^>nul') do (
copy "E:\1C_BackUp\%%I" "Z:\%year%\%month%_%monthM%"
copy "E:\1C_BackUp\%%I" "X:\%year%\%month%_%monthM%"
)
net use * /delete /yes
for /f %%A in ('dir "E:\1C_BackUp\*.rar" /a-d-s-h /b ^| find /v /c ""') do if %%A leq %minFiles% goto :eof
:loop
for /f "delims=" %%a in ('dir /b /a-d /t:w /o:d "E:\1C_BackUp\*.rar"') do (
cd /d E:\1C_BackUp
del "%%a"
goto :breakLoop
)
:breakLoop
for /f %%A in ('dir "E:\1C_BackUp\*.rar" /a-d-s-h /b ^| find /v /c ""') do if %%A gtr %minFiles% goto :loop