I have a .BAT file that renames all files numerically to a predefined name. I am trying to schedule this via SQL Agent job. I have verified that the folder that contains this .BAT is executable by my Domain User, and the SQL Agent job is using a Proxy that is my Domain User. Though I can go directly via Windows Explorer and double-click the .BAT to run, I cannot get it to run via SQL Agent job. I have also used the service account that the SQL Agent job runs under and used that as the default user in the Step Run As; this does not work either. I can't figure out why something so simple doesn't work. The only thing that I know is that the file sits on a different D drive, but I have also moved it to C drive and it won't work either. Please help!! The SQL Agent job runs successfully with no errors, but the .BAT file does not execute.
echo %0 - %date% %time% >> D:\Interfaces\Test\rename.log
for %%a in (MyFile*.txt) do (
set /a i+=1
copy "D:\Interfaces\Test\%%a" "D:\Interfaces\Test\Archive\%%a" >> D:\Interfaces\Test\rename.log 2>&1
ren "D:\Interfaces\Test\%%a" "FILENUM!i!.tmp"