Batch file runs at cmd.exe but exits with 0x1 when attempting to run in Schdueled tasks.
My intent is to delete all files with the .bak extention in Z:\ (this is a network share that is mapped on the local server) then copy the most recent .bak file to that directory
In Schedule tasks the Run = c:\WINDOWS\System32\cmd.exe /c D:\Copy2Share\FileCopy.bat
@ECHO OFF
rem This script Deletes all *.bak files
rem then Copies most recent .bak file to directory
set localdir=O:\SQL-Backup\
set destdir=Z:\
del /s "%destdir%*.bak"
for /f "delims=" %%a in ('dir "%localdir%*.bak" /b /od') do set "file=%%a"
copy "%localdir%%file%" "%destdir%" >nul
Your assistance is appreciated.
Doo4fun
Bookmarks