VBS

Warning

VBS is deprecated and old, JS is strongly suggested as scripting language.

VBS (Visual Basic Scripting) allows the use of all VBS objects inside Scanshare scripting.

The scripts are executed in a 32bits wrapped COM environment because there is no native 64bits VBS script component in modern Windows being VBS deprecated. This means that VBS scripts will never return the exact error and even on a syntax error there will be a generic COM error stopping the script, moreover VBS can use up to 2GB of RAM maximum being executed under a 32bits process.

Warning

Scripts are executed inside a Windows service hence interactive objects are strictly forbidden and if used they will cause the script to hang inside the no User desktop session of a Windows service.

Info

Based on the context where the script is used it may have different syntax and may require specific return values.

An example of VBS usage: create a workflow which allows you to browse to the folder you want to store the document in, from your MFP or PC Client.

You would create three scripts first:

Script 1

This script will store all folders in the root of the c: drive in” Results”, separated by semicolons. We assume that the selected value from the picklist is stored in metadata [DIR1].

StartingFolder="c:\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set Folder = fso.GetFolder(StartingFolder)
Set SubFolders = Folder.SubFolders
RESULT=""
For each folderIdx In SubFolders
RESULT=RESULT & folderIdx.Name & ";"
Next

Script 2

This script will store all child folders of the folder selected in the first script, and store them in RESULTS. We assume that the selected value from the picklist is stored in metadata [DIR2].

dir1 = Metadata.Values("DIR1")
StartingFolder="C:\Scans\" & dir1
Set fso = CreateObject("Scripting.FileSystemObject")
Set Folder = fso.GetFolder(StartingFolder)
Set SubFolders = Folder.SubFolders
RESULT=""
For each folderIdx In SubFolders
RESULT=RESULT & folderIdx.Name & ";"
Next

Script 3

This script will store all child folders of the folder selected in the second script, and store them in RESULTS.

dir1 = Metadata.Values("DIR1")
dir2 = Metadata.Values("DIR2")
StartingFolder="C:\Scans\" & dir1 & "\" & dir2
Set fso = CreateObject("Scripting.FileSystemObject")
Set Folder = fso.GetFolder(StartingFolder)
Set SubFolders = Folder.SubFolders
RESULT=""
For each folderIdx In SubFolders
RESULT=RESULT & folderIdx.Name & ";"
Next

Now all that needs to be done, is create a workflow, which asks three questions in the capture settings, each question referring to a VB Script to create a picklist, and storing the return value in metadata %DIR1%, %DIR2% and %DIR3%.

Previous Article

General

Next Article

JS