Scope

  • JobScheduler supports VBScript for implementation of jobs:
    • support for VBScript with a Master is available since long
    • support for ScriptControl:VBScript jobs with Agents is available with  JS-1623 - Getting issue details... STATUS
  • The support for VBScript includes that
  • Some minor differences exist between VBScript for Master and Agents, see Compatibility between VBScript and ScriptControl:VBScript.
  • VBScript language support is configured with
    • <script language="VBScript"> for execution with a Master
    • <script language="ScriptControl:VBScript"> for execution with Agents.

Background

  • VBScript is a scripting language that is not developed any further.by Microsoft.
  • The language is restricted to use with 32bit architectures:
    • In 64Bit environments VBScript can be executed from the command line by WoW64.
    • JobScheduler in a 64Bit environment can execute VBScript scripts.
    • However, VBScript is restricted to use the 32Bit registry and can load classes that are registered for a 32Bit environment only.
  • In future releases JobScheduler Master will become available for 64Bit environments only and will therefore drop support for VBScript. JobScheduler Agents can be executed with 32Bit environments and 64Bit environments, the architecture in use is determined by the Java Virtual Machine (JVM) in use.
    • Agents that are running with a JVM 32Bit (which is feasible within a 64Bit server architecture) integrate VBScript via ScriptControl.
    • ScriptControl is available for 32Bit only.
  • The intoduction of VBScript support for Agents offers a migration path for users of VBScript jobs:
    • Jobs can be migrated from execution with a Master to execution with Agents. 
    • Migration requires

Feature Availability

FEATURE AVAILABILITY STARTING FROM RELEASE 1.10.5

Examples

Example: Simple VBScript Job

Example: A simple VBScript job with some scripting similar to shell jobs might look like this:

Simple VBScript Job
<?xml version="1.0" encoding="ISO-8859-1"?>
<job process_class="Agent_Windows">
	<script language="scriptcontrol:vbscript">
		 <![CDATA[
Function spooler_process()

	spooler_log.info( spooler_job.name() )

    spooler_log.info( ".. merge parameters" )
	Set parameters = spooler_task.params()
    parameters.merge( spooler_task.order().params() )

    spooler_log.info( "parameter name1=" & parameters.value( "name1" ) )
    spooler_log.info( "parameter name2=" & parameters.value( "name2" ) )

	spooler_process = false
End Function
		]]>
	</script>
	<run_time />
</job>

Example: VBScript Job with Order API methods

Example: A simple VBScript job with some scripting similar to shell jobs might look like this:

VBScript Job with Order API methods
<job  process_class="Agent_Windows" stop_on_error="no" order="yes">
    <params >
        <param  name="name1" value="value1"/>
    </params>

    <script  language="scriptcontrol:vbscript">
        <![CDATA[
spooler_log.info( "id: " & spooler_task.order.id() )
spooler_log.info( "title: " & spooler_task.order.title() )

spooler_log.info( "state: " & spooler_task.order.state() )
spooler_log.info( "end state: " & spooler_task.order.end_state() )

Set jobChain = spooler_task.order.job_chain()
spooler_log.info( "job chain name: " & jobChain.name() )

spooler_task.order.set_state_text( "current state text" )
spooler_log.info( "state text: " & spooler_task.order.state_text() )

spooler_log.info( "next start time: " & spooler_task.order.string_next_start_time() )
spooler_log.info( "priority: " & spooler_task.order.priority() )
spooler_log.info( "suspended: " & spooler_task.order.suspended() )
spooler_log.info( "is Service: " & spooler.is_service() )

Set myJobChain = spooler_task.order.job_chain()
spooler_log.info( "job chain name: " & myJobChain.name() )

Set myParams = spooler_task.order.params()
spooler_log.info( "parameter name1=" & myParams.value( "name1" ) )

Set myVariables = spooler_task.order.params()
spooler_log.info( "params count: " & myVariables.count() )
myVariableNames = split( myVariables.names(), ";" )

For i = LBound(myVariableNames) to UBound(myVariableNames)
	spooler_log.info( "variable " & myVariableNames(i) & ": " & spooler_task.order.params.var( myVariableNames(i) ) )
Next

spooler_log.info( "order xml: " & spooler_task.order.xml() )
        ]]>
    </script>
    <run_time />
</job>

Example: VBScript Job with Job Chain API methods

Example: A VBScript job with some scripting similar to shell jobs might look like this:

VBSCript job with Job Chain API methods
<?xml version="1.0" encoding="ISO-8859-1"?>
<job  process_class="Agent_Windows" stop_on_error="no" order="yes" title="job_chain title" name="job_chain">
    <params >
        <param  name="name1" value="value1"/>
    </params>

    <script  language="scriptcontrol:vbscript">
        <![CDATA[
Set jobChain = spooler_task.order.job_chain()
spooler_log.info( "name: " & jobChain.name() )
spooler_log.info( "path: " & jobChain.path() )
spooler_log.info( "title: " & jobChain.title() )
spooler_log.info( "orders recoverable: " & jobChain.orders_recoverable() )
spooler_log.info( "order count: " & jobChain.order_count() )

Set orderQueue = jobChain.order_queue( spooler_task.order.state() )
spooler_log.info( "order queue length: " & orderQueue.length() )

Set jobChainNode = jobChain.node( spooler_task.order.state() )
spooler_log.info( "job chain node job name: " & jobChainNode.job.name() )
        ]]>
    </script>
    <run_time />
</job>

Compatibility between VBScript and ScriptControl:VBScript

  • Use of callback functions
    • VBScript jobs are required to implement as a minimum the callback function spooler_process().
    • ScriptControl:VBScript jobs can implement the spooler_process() function, however, they are not required to do so. Any script code that is added directly to the job script will implicitely be executed for a job step similar to spooler_process().
  • Use of the JobScheduler API
    • VBScriipt jobs make use of objects, methods and properties of the JobScheduler API for VBScript.
    • ScriptControl:VBScript jobs make use of objects and methods of the JobScheduler API for ScriptControl:VBScript
    • Syntactical differences include
      • With ScriptControl:VBScript no properties are available, instead the information can be accessed by methods:
        • VBScript example: spooler_task.id
        • ScriptControl:VBScript example: spooler_task.id()
      • With ScriptControl:VBScript assignments to properties are replaced by methods:
        • VBScript example: spooler_job.max_order_setbacks = 2
        • ScriptControl:VBScript example: spooler_job.set_max_order_setbacks( 2 )
      • With ScriptControl:VBScript assignments of more than one value to properties requires a Call statement:
        • VBScript example: spooler_job.delay_after_error( 2 ) = 10 ' A 10 second delay after the 2nd consecutive error
        • ScriptControl:VBScript example: Call spooler_job.set_delay_after_error( 2, 10 ) ' A 10 second delay after the 2nd consecutive error
      • Objects can be specified as methods:
        • VBScript example: spooler_task.order.params
        • ScriptControl:VBScript example: spooler_task.order.params and spooler_task.order().params()