• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1571
  • Last Modified:

scheduling robocopy to run at night

I need to backup a couple of folders across our network to a server which is backed up.   I am trying to use Robocopy to copy any changes over to the server before the nightly backup.

I created a batch file to run robocopy on both folders and used Windows Task Scheduler to set it to run every night.

I have made sure the batch file is correct.   If I run it manually by selecting it and telling it to run as administrator it runs fine.   However it never runs from the Task Scheduler.   The user I created the task with has administrator rights on the computer, I have selected Run wit Highest privileges  and Run whether user is logged on or not.    I tried changing the user or group to another administrator account, I tried changing it from a .bat file to a .cmd file.  I even scheduled two separate tasks with robocopy itself in the action and I still can not get it to run.  I have selected wake this computer to run this task and set the computer not to go to sleep

Program/script:  c:\windows\syswow64\robocopy.exe
add arguments: c:\data y:\data /S /z /r:5 /W:5 /log:y:\robocopy.log /NP

Y is mapped to the external folder and if I run this from the command line or in a batch file it works fine.

There are no errors in the logs.  I do not get any messages on the screen.  If I try to run it from Task Scheduler nothing happens. Both users I have tried have rights to the the files/folders

The computer is running Windows 7 64 bit.
1 Solution
ste5anSenior DeveloperCommented:
Does the account you're using with the Task Scheduler has the permissions to connect to y:? How is this drive mapped? Maybe it's not mapped at all..

1. store the log on a local drive.
2. use the UNC path instead of y:
3. use NET USE to connect to your backup drive.
You could add to your script the following line to see if the y: drive is connected:

Open in new window

WildChild84System AdministratorCommented:
If you launch the script with elevated privileges in task manager, probably you don't see the mapped drive. Try for example to map first  the drive and then run the script. You can check if it is visible by opening a cmd both as simple user or elevated user.
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Lionel MMSmall Business IT ConsultantCommented:
I never use the schedules task "add arguments feature" instead I would suggest you create a .bat file--lets say CopyFolders.Bat and then add these lines to it and save
net use y: /d /y
Net Use Y: \\servername\sharename
robocopy c:\data y:\data /S /z /r:5 /W:5 /log:y:\robocopy.log /NP
The replace the line is scheduled tasks in the actions tab with C:\Folder\CopyFolders.Bat with no arguments and see if that will work
qvfpsAuthor Commented:
The drive is mapped.  IF I sit down at the computer and pull up Windows Explorer the drive is there and I can view/edit files.

I have tried scheduling each copy separately by specifying Robocoy and by putting the commands in a .Bat and a .CMD file with the same results.  

 I have not tried mapping the drive as the first fist step in the file.  I will try using the UNC path and mapping the drive within the script and see if either work.  

Thanks for the suggestions
ste5anSenior DeveloperCommented:
@qvfps: That the drive is mapped, when you log on is almost meaningless.

The scheduled task runs normally under a different account (with local privileges only/no AD) and it's not interactive. Thus the normal logon script which is creating the mapped drive is also not executed.
Lionel MMSmall Business IT ConsultantCommented:
If you try the script completely, all the lines then the mapped drive drive will have the same credentials as the rest of the script--try it and let me know if it works.

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now