Date: Thu, 28 Mar 2024 16:19:37 +0000 (UTC) Message-ID: <1252314759.11711.1711642777980@change.sos-berlin.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_11710_1180929405.1711642777980" ------=_Part_11710_1180929405.1711642777980 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
A VBScript job in JS1 can look like this:
<job&= gt; <script language=3D"VBScript"><![CDATA[ function spooler_process() =20 spooler_log.info( "hello world" ) spooler_process =3D false =20 end function ]]></script> <run_time/> </job>
Explanation:
spooler_process()
callback function=
that is triggered by the Master or Agent.<include>
elements to reference files contain=
ing VBScript code (.vbs)..<job = process_class=3D"/agent_windows"> <script language=3D"scriptcontrol:vbscript"><![CDATA[ function spooler_process() =20 spooler_log.info( "hello world" ) spooler_process =3D false =20 end function ]]></script> <run_time/> </job>
Explanation:
scriptcontrol:vbscript
job type allows execution of th=
e job provided that the Agent is running for a 32bit JVM.VBScript jobs and JScript jobs can be executed from a shell job in JS7 u=
sing the cscript.exe
utility provided by the Windows operating=
system.
The cscript.exe
utility can be parameterized with the path =
to a Windows Script File (.wsf) that=
p>
Therefore the migration of JS1 VBScript jobs to JS7 includes running
The command in a JS7 job which executes VBScript can look like this:
c= script.exe //NoLogo C:\tmp\test.wsf
Explanation:
cscript.exe
utility is executed with the //=
NoLogo
switch to suppress unwanted output to stdout.c:\tmp\test.wsf
is use=
d as a parameter.There could be reasons for executing VBScript code in a 32bit context, e= .g. if the code makes references to the 32bit Windows Registry. In this sit= uation modify the command as follows:
%= WINDIR%\SysWOW64\cmd.exe /k cscript.exe //NoLogo C:\tmp\test.wsf
Explanation:
%WINDIR=
%\SysWOW64\cmd.exe /k
that precedes the call to the cscript.ex=
e
utility.cscri=
pt.exe
utility in this context.A Windows Script File (.wsf) is an XML file that includes references to = files holding VBScript code (.vbs):
&= lt;?xml version=3D"1.0" ?> <job id=3D"none"> <script language=3D"VBScript" src=3D"c:\tmp\JS7_SpoolerClasses.vbs"/&g= t; <script language=3D"VBScript" src=3D"c:\tmp\test_01_include1.vbs"/> <script language=3D"VBScript" src=3D"c:\tmp\test_01_include2.vbs"/> <script language=3D"VBScript" src=3D"c:\tmp\test_01.vbs"/> </job>
Explanation:
If VBScript jobs in JS1 have used the JobScheduler Job API, e.g. for logging purposes and reading paramet= ers then they have to be migrated.
Users can modify the code to apply VBScript replacement functions or the= y can create a compatibility class that implements the Job API calls used i= n VBScript code of jobs.
Users can check for native VBScript functions as a replacement for JS1 A= PI methods like this:
Logging
spooler_log.info( "hello wo=
rld" )
WScript.StdOut.WriteLine "hel=
lo world"
spooler_task.params( "some_=
parameter" )
wshShell.ExpandEnvironmentStr=
ings( "%SOME_PARAMETER%" )
If the number of JS1 Job API methods used in VBScript code is somewhat l= imited then a VBScript class can be created that implements compatible meth= ods and properties such as
spooler_log.info()
spooler_task.prams()
spooler_task.changed_directories()
spooler_job.order_queue
The implementation of the compatibility class can look like this:
Class SpoolerOrderQueue Public order_queue Public Function get_order_queue() get_order_queue =3D order_queue End Function End Class Class SpoolerJob Private wshShell Public order_queue Private Sub Class_Initialize() Dim result Set wshShell =3D CreateObject( "WScript.Shell" ) If ( wshShell.ExpandEnvironmentStrings( "%JS7_ORDER_ID%" ) <>= "%JS7_ORDER_ID%" ) Then set order_queue =3D new SpoolerOrderQueue Else set order_queue =3D Nothing End If End Sub End Class Class SpoolerLog Public Sub Info( message ) WScript.StdOut.WriteLine message End Sub End Class Class SpoolerTask Private wshShell Public trigger_files =20 Private Sub Class_Initialize() Set wshShell =3D CreateObject( "WScript.Shell" ) If ( wshShell.ExpandEnvironmentStrings( "%FILE%" ) <> "%FILE%= " ) Then trigger_files =3D wshShell.ExpandEnvironmentStrings( "%FILE%" ) Else trigger_files =3D vbNull End If End Sub Public Function Params( name ) Dim result result =3D wshShell.ExpandEnvironmentStrings( "%" & UCase(name)= & "%" ) If ( result =3D "%" & UCase(name) & "%" ) Then Params =3D vbNull Else Params =3D result End If End Function Public Function Changed_Directories() Dim result result =3D wshShell.ExpandEnvironmentStrings( "%FILE%" ) If ( result =3D "%FILE%" ) Then Changed_Directories =3D vbNull Else Changed_Directories =3D result End If End Function End Class Class SpoolerGlobal Private wshShell Private Sub Class_Initialize() Set wshShell =3D CreateObject( "WScript.Shell" ) End Sub Public Function Variables( name ) Dim result result =3D wshShell.ExpandEnvironmentStrings( "%" & UCase(name)= & "%" ) If ( result =3D "%" & UCase(name) & "%" ) Then Variables =3D vbNull Else Variables =3D result End If End Function End Class Set spooler_job =3D new SpoolerJob Set spooler_log =3D new SpoolerLog Set spooler_task =3D new SpoolerTask Set spooler =3D new SpoolerGlobal
Explanation:
spooler_lo=
g.info()
method.spooler_log
object and similar objects are created whe=
n including the class file.