Batch Scripting (Windows)


In order to facilitate using FreeFileSync and RealtimeSync in advanced synchronization scenarios, creating batch files is a good way to provide additional functionality. The following section will give some general hints for custom *.cmd and *.bat files.


Example: A simple locking facility – (Note: FreeFileSync already has a more powerful directory locking mechanism implemented that allows multiple writers in parallel)

     

  1. When starting a batch file from RealtimeSync be sure to make synchronous calls to FreeFileSync only. This will prevent RealtimeSync from detecting changes while synchronization is still in progress.

     

  2. During execution of a Batch file a black console window is shown. You can hide this window by using the Visual Basic script "Invisible.vbs" located in the FreeFileSync installation directory.

    Usage:

    wscript C:\Program files\FreeFileSync\Invisible.vbs C:\MyBatchFile.cmd


     

  1. FreeFileSync returns with an Errorlevel below zero if unresolved problems remain:

    "C:\Program Files\FreeFileSync\FreeFileSync.exe" "H:\Silent_Config.ffs_batch"
    if not errorlevel 0 (
      
    ::if something went wrong, add special treatment here
      echo Errors occurred during synchronization...
      pause
    )