New
#1
Trying to Sync Data Between Two Windows 10 Systems w/ .bat Script
I have two systems that I use regularly that contain the same files. I'd like to automate the synching of this data between these two systems. I'd originally read up on various ways to accomplish this, and I wanted to stay away from canned solutions as much as possible, so I settled on using robocopy in a .bat file and running it via Task Scheduler. However, when running the job, it would report as completed, yet no data was transferred. Further, it was pointed out to me that running this script concurrently was an inherently bad idea, since one job would perform an update, while the other would destroy its files. Thus, I'm looking for two things: 1) The correct methodology for running sync scripts between two systems w/ Task Scheduler, and 2) The correct setup of the scripts and Task Scheduler, so the job(s) complete properly.
Here's all the pertinent information pertaining to my systems:
I have two systems, System_A running Windows 10 Pro and System_B running Windows 10 Home, which are both on v20H2 (OS Build 19042.928). I log into both systems using my Microsoft user account, rather than a local account. I've also shared the desktops on each system, and the Microsoft user was granted full privileges on each share.
The .bat files were stored on the respective desktops of each system, and they were scheduled to run every three minutes (I now understand that this was not a good idea.)
System_A sync.bat:
System_B sync.batCode:cd C:\Users\username\OneDrive\Desktop robocopy C:\Users\username\OneDrive\Desktop\directory_to_sync '\\System_A\Desktop\directory_to_sync' /E /MIR /mt /z
Using System_A's sync.bat as an example, this is the configuration of the Task Scheduler settings:Code:cd C:\Users\username\Desktop robocopy C:\Users\username\Desktop\directory_to_sync '\\System_B\Desktop\directory_to_sync' /E /MIR /mt /z
General Tab:
The Microsoft user account is the assigned user account.
The task is set to run whether user is logged on or not.
The task runs w/ highest privileges.
I changed the configuration from Vista/Server 2008 to Windows 10.
Triggers:
The task begins at task creation/modification.
The task will stop if it runs longer than three hours.
Actions:
Action: Start a program
Program/script: cmd
Add arguments (optional): /c sync.bat (Note: The "/c" was auto-added, after I input "sync.bat."
Start in (optional): C:\Users\username\OneDrive\Desktop
Conditions:
The task is set to run when any network connection is available.
Settings:
The task is set to be run on demand.
The task is set to run ASAP, when a scheduled start is missed.
If the task fails, it will restart every minute and attempt to do so up to three times.
The task will be stopped, if it runs longer than three hours.
If the task is running, and a request doesn't stop it, it's set to force it to stop.
If the task is already running, a new instance of the task is not to start.
The job history reported that it completed w/ an operational code of 2, but nothing synched. Now that I understand that running concurrent jobs is not the way to go, I'd like to know the best way to sync this data, as well as what to change in my settings. Any help would be greatly appreciated. Thank you!