Skip to main content

Windows Agent environment variables

Theme: Overview
Who Is It For? Automation Engineer

What is it?

The Windows Agent defines several environment variables for each job it starts. These variables give jobs access to OpCon execution context — such as job name, schedule, and output paths — without requiring that information to be passed as command-line arguments.

  • Access the OpCon job name, schedule name, schedule date, and frequency from within any running job
  • Reference the agent's installation directory and job output file path dynamically, without hardcoding values

When to use

  • When a script or program needs to know its OpCon job name, schedule name, or schedule date at runtime.
  • When building portable scripts that reference the agent's installation directory or job output file path without hardcoding values.

Benefits

  • Jobs can reference OpCon execution context without requiring metadata to be explicitly passed as command-line arguments, simplifying job definitions.
  • Scripts become portable across agent machines because paths like the installation directory and job output file are resolved dynamically at runtime.
Environment variableDescription
SMA_MSLSAM_JOB_NAMEThe name of the job defined in OpCon.
SMA_MSLSAM_JOBOUTPUT_FILENAMEThe full path of the job output file created for the current job.
SMA_MSLSAM_LSAM_NAMEThe name defined in the OpCon database for this agent.
SMA_MSLSAM_PRERUN_ACTIVEA value of TRUE or FALSE indicating whether the currently running job process is a prerun job or a main job.
SMA_MSLSAM_RESTART_STEPThe optional restart step sent to the agent for the job in the SMA_MSLSAM_JOB_NAME variable.
SMA_MSLSAM_ROOT_DIRECTORYThe path to the directory where the agent is installed.
SMA_MSLSAM_SAM_JOB_IDA 27-character unique job ID that identifies this job in the agent's tracking system.
SMA_MSLSAM_SCHEDULE_DATEThe date of the schedule containing the job in the SMA_MSLSAM_JOB_NAME variable.
SMA_MSLSAM_SCHEDULE_FREQThe schedule frequency of the job in the SMA_MSLSAM_JOB_NAME variable.
SMA_MSLSAM_SCHEDULE_NAMEThe name of the schedule containing the job in the SMA_MSLSAM_JOB_NAME variable.
SMA_MSLSAM_DATA_DIRECTORYThe path to the agent's data directory, where configuration and data files such as MSLSAM.ini are stored. Distinct from the installation directory provided by SMA_MSLSAM_ROOT_DIRECTORY.
SMA_MSLSAM_ECOF_DIRECTORYThe directory the agent monitors for Exit Code Override Files (E.C.O.F.). Corresponds to the DefaultECOFDirectory setting in MSLSAM.ini.

FAQs

Are these environment variables available in all job types, including scripts and executables?
Yes. The agent defines these variables for every job process it starts, regardless of whether the job runs a batch script, executable, or command line. Any process started by the agent inherits these variables.

How do I reference these variables in a batch script?
Use standard Windows batch variable syntax: %SMA_MSLSAM_JOB_NAME%, %SMA_MSLSAM_SCHEDULE_DATE%, etc.