MirrorFolder 6.0
User's manual
Execute

You can set custom commands to be executed before and after archiving of the source folder 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 archiving 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.
  • {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 archival of the source folder 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 archiving of the source folder.

Execute this command after completion

Enter the full path name of a local file to be executed after the archival 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 archival of the source folder.

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 archival process, i.e., it was not successful.

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

You can use the above feature to run external commands before and after the archival 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 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 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 archival to a VeraCrypt container file, you can use the full path name of "VeraCrypt.exe" as both pre-task and post-task commands 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 pre-task command.

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