MirrorFolder 6.1
User's manual
 
Loading...
Searching...
No Matches
Execute

You can set custom commands to be executed before and after synchronization on this property page.

Execute

Execute this command before starting

Enter the full path name of a local file of type, .exe, .cmd, .bat, or .ps1, to be executed before starting the synchronization process. You may also optionally enter the command line argument below this path name field.

Command line arguments (optional)

You may optionally enter the command line argument here to be passed during execution. The following internal variables are available in the command line argument. They will be replaced by their respective values before executing the command.

  • {SrcRoot} - root drive or UNC path name of the source path.
  • {SrcPath} - full source path name.
  • {MrRoot} - root drive or UNC path name of the mirror path.
  • {MrPath} - full mirror path name.
  • {ArcvRoot} - root drive or UNC path name of the archive path.
  • {ArcvFile} - full archive file path name.

Abort on failure

Select this option to abort synchronization in case the command fails, i.e., it returns a value greater than zero.

Wait for completion

Select this option to wait for the command to complete before starting synchronization.

Execute this command after completion

Enter the full path name of a local file to be executed after the synchronization process is over, with or without success. You can also provide optional arguments for this command below.

Only on successful completion

Select this option if you want to execute the above command only on successful completion of synchronization.

Only if there is any error

Select this option if you want to execute the above command only if there is some error completing the synchronization process, i.e., it was not successful.

Wait for completion
Select this option to wait for the command to complete after completion of the synchronization.

You can use the above feature to run external commands before or after the synchronization process, like mounting and dismounting of encrypted container files. For example, the following PowerShell scripts can be used to mount and dismount a BitLocker encrypted VHD file. The mount command will be the full path name of the "mount-vhd.ps1" script file with the argument as "-p MyPassword full_path_name_of_vhd_file", while the dismount command will be the full path name of "unmount-vhd.ps1" script file with the argument as the full path name of the VHD file.

mount-vhd.ps1:

# Mounts a virtual disk and optionally unlock BitLocker encrypted drive
# mount-vhd.ps1 [-p bitlocker_password] vhd_file_path
#
Param([Parameter(Mandatory=$true)][string]$file,[Parameter(Mandatory=$false)][Alias('p')][string]$pass)
$drv = (Mount-DiskImage -ImagePath $file -PassThru | Get-Disk | Get-Partition | Get-Volume).DriveLetter
if ($pass)
{
$SecureString = ConvertTo-SecureString $pass -AsPlainText -Force
Unlock-BitLocker -MountPoint $drv -Password $SecureString
}

unmount-vhd.ps1:

# Unmount a virtual disk
# unmount-vhd.ps1 vhd_file_path
#
Param([Parameter(Mandatory=$true)][string]$file)
Dismount-DiskImage -ImagePath $file

For synchronizing to a VeraCrypt container file, you can use the full path name of "VeraCrypt.exe" as both a pre-task and a post-task command for mounting and dismounting the container. The arguments for mounting and dismounting the container will be "/m rm /nowaitdlg /q /s /p MyPassword /v full_path_name_of_veracrypt_container_file" and "/nowaitdlg /q /s /d {MrRoot}" respectively. You should also select "Abort on failure" and "Wait for completion" options for mounting, i.e., for the pre-task command.

Note
We recommend that you put any script file to be executed during synchronization under the 'scripts' sub-folder of the MirrorFolder installation path so that they can't be modified without administrative privileges.