Execute Visual Basic Scripts
This profile property allows Visual Basic scripts to be executed at profile start or profile end. This enables custom tasks to be performed as part of your backup — both before and after a copy operation. This feature is available starting with the AllSync Professional Edition.Contents
- Requirements and Notes
- VB Script Table
- Placeholders
- Options
- Example Scripts
- Helpful Websites on VB Scripts
Requirements and Notes
- Visual Basic Script (VBScript) is a scripting language developed by Microsoft for automating tasks in Windows environments.
- The Windows Scripting Host must be installed on your system for AllSync to execute VB scripts. This can be verified, for example, by running the sample script Test.vbs.
- Properties and methods of the WScript object must be used without the WScript. prefix. Instead of WScript.CreateObject, simply use CreateObject.
- Some methods such as Sleep or Echo are unavailable or only partially usable in scripts.
- VB scripts that use the WScript object can alternatively be executed via the profile property 'Start Programs' (e.g. wscript.exe test.vbs) to bypass limitations.
- A profile can be aborted if the script returns the error code -99 or assigns the value -99 to a variable named ExitCode. In both cases, no error message is shown in the log. See example script CheckDestinationFolder.vbs.
VB Script Table
This table lists all VB scripts that will be executed at profile start or profile end. Activation is done via the checkbox in front of the script name.Table Columns
- Execution Time
Indicates when the script should be executed: at profile start or profile end. - Start Conditions
Indicates under which conditions the script should be executed:- When manually starting a copy operation
- When creating a copy preview
- When processing a copy preview
- When started by a Scheduler Task
- When started via command line
- Wait Time
Specifies after how many seconds the script will be automatically terminated. If the wait time is set to 0 seconds, the script will not be automatically terminated.
Buttons
- Create New VB Script
Creates a new VB script. - Select VB Script
Allows selection of an existing VB script. - Edit VB Script
Allows editing the settings of a VB script. - Remove VB Script
Removes a VB script from the table. - Start VB Script
Executes the selected VB script. - Move VB Script Up in Table
Moves the selected VB script one row up in the table. - Move VB Script Down in Table
Moves the selected VB script one row down in the table.
Placeholders
The following placeholders can be used in VB scripts:| Placeholder | Description |
|---|---|
| [SourceX] | X is replaced with a number representing an activated source folder in the source folder list. For example, [Source1] represents the first activated source folder, [Source2] the second, and so on. |
| [DestinationX] | X is replaced with a number representing an activated destination folder in the destination folder list. For example, [Destination1] represents the first activated destination folder, [Destination2] the second, and so on. |
| [Profil] | Profile name |
| [ErrorCount] | Number of errors |
| [CopyToSource] | Amount of data in bytes copied from destination to source |
| [CopyToDestination] | Amount of data in bytes copied from source to destination |
Options
- Cancel profile if a VB script ended with an error
The profile is aborted if an error occurs in the script or if the script could not be executed at profile start. An error message is shown in the log unless the script returns the special error code -99.
Example Scripts
All example scripts are located in the 'Scripts' folder. If you want to use one in your profile, save it under a different name — otherwise it will be overwritten during an update.Available example scripts:
- CheckDestinationFolder.vbs
This script checks whether the first destination folder exists. It returns the error code -99 if the folder cannot be found. See the option 'Abort profile if a program ends with an error'. - CheckDestinationFolderWithMessageBox.vbs
This script checks whether the first destination folder exists. A message window is displayed if the folder is not found. The user can then choose to retry the check or abort the profile. - CloseApp.vbs
This script allows you to terminate running programs. - ExportRegistry.vbs
This script allows you to save a registry branch to a file in the destination folder. - IsDestinationFolderEmpty.vbs
This script checks whether the first destination folder exists. It returns the error code -99 if the destination folder is empty. See the option 'Cancel profile if a program returns an error'. - KillTask.vbs
This script allows you to terminate a Windows task. You can obtain the required task name via the Windows Task Manager. - MessageBoxWithTimer.vbs
This script displays a confirmation dialog to the user for 5 seconds. The script returns the error code -99 if the user clicks the Cancel button. See the option 'Cancel profile if a program returns an error'. - Outlook.vbs
This script terminates the Microsoft Outlook application. - OutlookExpress.vbs
This script terminates the Microsoft Outlook Express application. - RenameFileAndCreateFileHistory.vbs
This script renames the file copy.txt by appending an ascending sequence number to the filename to create a file history. You can use this script, for example, with the log option 'Copy profile log file to each destination folder'. Start this script before a copy operation to rename the existing log file in the destination folder.
Example: copy.txt → copy0001.txt, copy0002.txt, ... - Run.vbs
This script allows you to start any program by assigning the program path to the variable Prg. - ScreensaverOn.vbs \ ScreensaverOff.vbs
These two scripts allow you to activate or deactivate the screensaver. - Test.vbs
This script tests the functionality of Microsoft Windows Scripting on your system and provides a brief overview of the capabilities of Visual Basic Scripting.





