I'm attempting to put together a batch file that will set up a robocopy task as a service in response to user input. The basic idea being that the user will input MyRobocopyBatchFile.bat sourceFolder destinationMachine and from then on the contents of the folder mirrored with a known folder on the destinationMachine. Service will be set to start automatically so it will run at startup. For this I've taken queues from this question
The target environment for this is WindowsServer 2008 R2
My intention for how to do this is
set destination=\\%2\RunSheets set source=%~dp0%1 echo Setting source to %source% echo Setting destination to %destination% set serviceName=RunSheetCopy%2 sc create %serviceName% binPath= "c:\Windows\System32\robocopy.exe %source% %destination% /MIR /MON:1 /v /log:C:\Logs\RoboCopy\%serviceName%.log /LEV:1" start= auto DisplayName= %serviceName% sc start %serviceName%
with user input something like:
MyRobocopyBatchFile.bat .\RunSheets 10.20.30.40
The problem that I am facing is that when the batch file gets to starting the service it gives me an error message. The same error message occurs when starting with NetStart or via the services window. The error message is:
[SC] StartService FAILED 1053: The service did not respond to the start or control request in a timely fashion.
Despite the error message robocopy is syncing the directories but it does not continue in monitor mode.
If any help with how to get robocopy running as a service would be greatly appreciated.
N.B. The product manager is very keen on the idea of a service.
UPDATE: Since there was no way to do this in a mechanism that would make the PM happy (SrvAny, being legacy was not an option), I ended up going with hacking together a service wrapper for RoboCopy, Its not the solution that I would have liked but it will do the job.