Link to home
Create AccountLog in
Avatar of colinasad
colinasadFlag for United Kingdom of Great Britain and Northern Ireland

asked on

RoboCopy fail in Windows Task Scheduler

I suspect/hope this is a fairly low-tech issue with a simple answer.

I am using a DELL Latitude Laptop running Windows 10 Pro, with a high-capacity Synology NAS Drive attached.

Using the Windows Task Scheduler I have run a few "Xcopy" ".bat" files to copy files from the Laptop's hard disk to the NAS Drive in the small hours of the morning.

Some Xcopy commands had trouble with large database files so I am trying to use "RoboCopy" instead.

My problem is that one one my "RoboCopy" ".bat" files (attached) works OK when I launch it by double-clicking on the file itself ("successful" screenshot attached), but when I try to run the same ".bat" file from a "task", it starts OK but very quickly displays an error message saying it cannot find (or create?) the destination path ("failed" screenshot attached). The command in the ".bat" file is :


RoboCopy "C:\Users\Colin\Documents" "V:\Documents" /E /DCOPY:DAT /R:3 /W:3

Another very similar "RoboCopy" ".bat" file works OK when it is launched by the Task Scheduler.

Can anyone put be right on why my "Documents" RoboCopy does not work? Is it some sort of security imposed on a User's "Documents" folder that kicks-in with Task Scheduler? Can it be worked around?

Many thanks. Colin.RoboCopy_Success.JPGRoboCopy_Fail.JPG


ASKER CERTIFIED SOLUTION
Avatar of NVIT
NVIT
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer

I will guess that the scheduled task runs as a different user, and I also am assuming that "V" is a mapped drive which is a per user setting... Change the bat file to either use a full unc path if it is a mapped drive, or at a minimum to run as the same user you log in with... OR run a command to map the drive before the robocopy command...

Hello Colinsad,


are you sure that the V: unit is present and accessible when the scheduled task is run?


We don't see the exact syntax of the successful running.


Some parameters of the tasks are probably not identical for the failing task:

- Account with password provided for the task

- Task can run without open session

- Select the option to have the maximum of privileges for the task


Add some comments and test command in your script to verify the situation.

- DIR V:\


Some special folders can be a problem during the copy, but it shouldn't fail at the first file.


Avatar of colinasad

ASKER

Yes; "V:" is a mapped drive letter for a shared folder on my NAS Drive. When I changed my RoboCopy command to use the full "share name" path rather than the mapped drive letter, the Scheduled Task ran OK.

Not sure why my other RoboCopy commands for other folders ran OK just using their mapped drive letters, but I'm not going to worry about that.

Thanks for all your help. Colin.

I JUST missed that one by minutes... NVIT beat me to it... ;)