scheduling robocopy to run at night

Posted on 2014-08-16
Last Modified: 2014-08-19
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.
Question by:qvfps
    LVL 31

    Expert Comment

    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.
    LVL 3

    Expert Comment

    You could add to your script the following line to see if the y: drive is connected:

    Open in new window

    LVL 2

    Expert Comment

    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.
    LVL 24

    Accepted Solution

    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

    Author Comment

    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
    LVL 31

    Expert Comment

    @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.
    LVL 24

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    The use of stolen credentials is a hot commodity this year allowing threat actors to move laterally within the network in order to avoid breach detection.
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    The viewer will learn how to back up with the free utility from runtime software, DriveImageXML using Windows 7. Download DriveImageXML from Open folder where it was saved: Start installation by double clicking the install scrip…
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now