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.
qvfpsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
0
telczj9Commented:
You could add to your script the following line to see if the y: drive is connected:
IF NOT EXIST Y: ECHO Y: DRIVE WAS NOT ACCESSIBLE > C:\MY_LOG.TXT

Open in new window

0
Maurizio GhielmettiSystem 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.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
0
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.
0
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.