Introduction
This article describes how to use the Run VBScript
The Run VBScript tool is used to create a task step that runs a Visual Basic Script using data produced by other steps in the task. tool to decode a Base64 encoded file back into its original form.
Adding the Required Script
As all processing is carried out in the Run VBScript tool, you can add this step to an existing task or isolate it in a separate task.
Note: You must know the original file extension in order for this decoding to be successful.
- Add a Run VBScript step to the relevant task.
- Add a meaningful Name for this step.
- Go to the Main tab and enter the following script:
inputFile = "<folder_path_and_filename>"
outputFile = "<folder_path_and_filename>"
Set fso=CreateObject("Scripting.Filesystemobject")
Set input=fso.OpenTextFile(inputFile,1)
contents = input.ReadAll()
input.Close
Set oXML = CreateObject("Msxml2.DOMDocument")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.text = contents
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = 1 'adTypeBinary
BinaryStream.Open
BinaryStream.Write oNode.nodeTypedValue
BinaryStream.SaveToFile outputFile
where folder_path_and_filename is the full path and filename to the encoded file (inputFile) and the full path and filename of where the decoded file should be saved (outputFile).
- Click OK to save and close the step.
When the task is run, the decoded version of the file is saved to the location specified in the outputFile variable. This can then be used by those BPA Platform tools that can consume physical files.