7

The /MON:1 option works just great and run directory scan if only changes happened. This is something that is not possible to do if robocpy is ran from windows scheduler each 10 min.

Is there a way to run the

robocopy  \\192.168.1.100\D$\RoboCopyTest \\192.168.1.200\D$\RoboCopyTest /FFT /Z /ETA /E /XA:H /R:0 /W:1 /XO /NP /NDL /NFL /MON:1

command automatically when windows starts, and if the command was stopped for some reason - restart it and notify to windows event log that the command was stopped for some reason. The robocpy command with /MON:n option has infinite loop to run itself only if files had N changes.

1
  • 1
    I get this error no matter how I tweak it: *** > The Robocopy Svc service failed to start due to the following error: > The service did not respond to the start or control request in a > timely fashion. *** help?
    – user236497
    Aug 7, 2014 at 4:58

2 Answers 2

6

You may be better off creating a Windows Service for this instead of running it from the task Scheduler. The Service framework is designed around this start-once-run-forever kind of program and has hooks for eventing in case of unknown stoppage.

Creating a user-defined service is pretty easy. Though the article is designed for Windows 2000, it still works for 2008. The 'sc' command is used to create the service.

sc create "Robocopy-Service" binPath= "c:\tools\robocopy.exe" start= auto

Change the values based on how you want the service to run. Once it's there, you can go into the Service Manager and modify the service for how to handle sudden stopping. It'll always record and event ("Service xyz stopped unexpectedly") but you can tell it how to restart the service, or run a script if you need to send emails about it.

2
  • 1
    But how do you pass the parameters to robocopy?
    – simon
    Dec 20, 2012 at 10:10
  • I'm also having troubles passing in parameters.
    – Klee
    Apr 6, 2014 at 23:33
9

To Expand on the above responses and provide parameters to robocopy:

sc create "Robocopy Service" binpath="c:\windows\system32\robocopy.exe /JOB:robocopy"

This will read the robocopy.rcj file that contains all parameters.

You can execute the robocopy command with all the desired parameters and add the /SAVE:robocopy command to create the robocopy.rcj file. You can then modify the parameters by simply editing the robocopy.rcj file.

1
  • Where is the robocopy.rcj file created? How can I specify the path? Mar 31, 2016 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .