Customizing job processing on a Windows workstation - jobmanrc.cmd

About this task

A standard configuration script template named TWS_home\config\jobmanrc.cmd is supplied with HCL Workload Automation. It is installed automatically as TWS_home\jobmanrc.cmd. You can use this command file to set the required environment before each job is run. To alter the file, make your modifications in the working copy (TWS_home\jobmanrc.cmd), leaving the template file unchanged. The file contains variables which can be configured, and comments to help you understand the methodology. Variables defined by default in the jobmanrc.cmd file describes the jobmanrc.cmd variables.
Table 1. Variables defined by default in the jobmanrc.cmd file
Variable Name Value
HOME The path to the TWS_home directory
POSIXHOME The path to the TWS_home directory in a POSIX complaint format
LOCAL_RC_OK
  • If set to yes, the user's local configuration script is run, if existing.
  • If set to no, the presence of a local configuration script is ignored. Any other setting is interpreted as no.
MAIL_ON_ABEND
  • If set to YES, an email is sent to the email ID defined in the email_ID variable, if the job ends in error.
  • If set to any value other than YES or NO, an email is sent to the email ID specified in this variable if the job ends in error.
  • If set to NO, no messages are sent if the job ends in error.
For more details, see Customizing the MAIL_ON_ABEND section of jobmanrc.cmd.
Running multiple Windows commands in a single job

By default, if you define a job to run two or more Windows commands or .CMD files separated by the ampersand (&) character, only the first command runs and subsequent commands are ignored.

To run a chain of commands (for example, cmd1.cmd & cmd2.cmd), you must modify the jobmanrc.cmd file as follows:
  1. Modify the jobmanrc.cmd script
    Update the following functions in your jobmanrc.cmd file:
    • Update the :getargs function:
      Ensure the function is defined exactly as shown below:
      :getargs
      set ARGS=%*
    • Update the :launch_args function:
      Modify the logic to handle the command chain and include the no_local_rc logic for string parsing:
      :launch_args
      REM Launch job based on ARGS (JCL)
      if /I "%LOCAL_RC_EXISTS%"=="YES" (goto :yes_local_rc) else (goto :no_local_rc)
      
      :yes_local_rc
      "%USERPROFILE%\jobmanrc.cmd"
      goto :continue
      
      :no_local_rc
      set doublequote=%ARGS:~0,1%
      set TEST=%doublequote:"=X%
      
      if "%TEST%" == "X " (goto :remove_and_launch) else (goto :launch)
      
      :launch
      call %ARGS%
      goto :continue
      
      :remove_and_launch
      call %ARGS:~1,-1%
      goto :continue
      
      :continue
      Note: Ensure there are two spaces after the X in the line if "%TEST%" == "X ".
  2. Update the Job Definition

    To prevent jobmanrc.cmd from interpreting the ampersand (&) as a script separator during its own internal logic, you must wrap the command in an additional set of double quotes within the job definition. The script logic added in Step 1 (call %ARGS:~1,-1%) automatically removes these extra quotes just before the command starts.

Example: Updating a composer definition

Change a standard definition:
WIN-V91#CHAIN
DOCOMMAND "dir & echo hi"
STREAMLOGON mdm91
DESCRIPTION "Added via composer."
TASKTYPE WINDOWS
RECOVERY STOP
To the modified version with escaped double quotes:
WIN-V91#CHAIN
DOCOMMAND "\"dir & echo hi\""
STREAMLOGON mdm91
DESCRIPTION "Added via composer."
TASKTYPE WINDOWS
RECOVERY STOP