Trying to Sync Data Between Two Windows 10 Systems w/ .bat Script

  1. Posts : 8
    Windows 10 Pro

    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:
    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
    System_B sync.bat
    cd C:\Users\username\Desktop  
    robocopy C:\Users\username\Desktop\directory_to_sync '\\System_B\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:

    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.

    The task begins at task creation/modification.
    The task will stop if it runs longer than three hours.

    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

    The task is set to run when any network connection is available.

    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!
      My Computer

  2. Posts : 16,895
    Windows 10 Home x64 Version 22H2 Build 19045.4170

    RoboCopy is not part of your solution unless one of your computers is the master and all you are trying to do is make the other computer the same as the master .

    If changes to your files might be made on either of your computers then RoboCopy is not the solution [and there is no alternative syncing command]. You will need to consider a third-party syncing utility or saving all the files of both computers in a single location instead [e.g. on OneDrive].

      My Computer

  3. Posts : 8
    Windows 10 Pro
    Thread Starter

    Thank you for your response. I had read multiple forums and thought that I could use robocopy to mirror data, such as in this example, but maybe going w/ a remote data source is the best bet.
      My Computer

  4. Posts : 16,895
    Windows 10 Home x64 Version 22H2 Build 19045.4170

    Yes, RoboCopy will mirror files. But that is only one way [changes in the RoboCopy Source are reflected in the Destination]. It is not syncing [a term that means two-way working - changes in both computers are copied to the other].

    Whether the source is local or remote makes no difference. There can only be a single source for RoboCopy.

    I'm not trying to tell you not to use RoboCopy but I am warning you that you can only use it if one of your computers is the master. It is not a syncing utility.
    - I use RoboCopy all the time. My main computer is the master and I use RoboCopy to update my other computers with all changes that have been made in the master.

    There are several syncing utilities around.
    - I used to use the MS utility SyncToy but I would never use it again. Whilst it would report some sync failures it would not report all sync failures so it was inherently unreliable.
    - The subject has been raised in several TenForums threads. These are merely the sync-related threads that I have kept links to
    How to Use SyncToy for Data Backups
    How do I sync files and folders in different paths?
    Sync Windows 10 files on 2 identical Pcs
    Best way to Sync from source to multiple locations?
    How do I backup files with Robocopy instead of Synctoy
    Syncing Thumb Drive

      My Computer

  5. Posts : 8,094
    windows 10

    If you login to the same ms account on both pc windows sync will do it automatically. Another option is free Google backup and sync which will do it instantly a file is changed
      My Computer

  6. Posts : 16,895
    Windows 10 Home x64 Version 22H2 Build 19045.4170

    Samuria said:
    If you login to the same ms account on both pc windows sync will do it automatically.
    This tutorial describes the syncing that MSAccounts can do - Turn On or Off Sync Your Settings - TenForumsTutorials
    - I suppose that's what was meant above but it does not seem to me to be sufficient [if I have understood the thread correctly].

    You could use OneDrive for all your files on all your computers and that would achieve the same as syncing between them. But your files would be in the cloud.
    Enable or Disable OneDrive Integration - TenForumsTutorials

      My Computer

  7. Posts : 8
    Windows 10 Pro
    Thread Starter

    Thank you both for your recommendations. I'll read up on Windows Sync to see if it fits my needs. If so, I'll come back, and mark this thread solved. Thank you, again!
      My Computer


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 21:28.
Find Us

Windows 10 Forums