Skip to end of metadata
Go to start of metadata


Is it possible to monitor a directory like c:\tmp\jobscheduler\files\incoming and look for strings in text files that then trigger a job to start a Microsoft Access macro with the string found in that file?

Looking for string in file like “FF040614CA” and then start C:\Program Files (x86)\Microsoft Office\OFFICE11\MSACCESS.exe q:\companyX\FF040614CA\U4284.mdb /x mkrU4284



  • Download the attached archive:
  • Unzip the archive to the live folder of your JobScheduler installation
  • Adjust the configuration to your environment


  • A job chain that monitors the directory for incoming files
  • Two jobs that process incoming files in sequence:
    • Check the file for a string: if the string is available then the job chain is continued otherwise it is terminated.
    • Start MS Access with the matching string found from the file


Job Chain: watch_files

Basically you would set-up a job chain that monitors the directory for incoming files like this:


  • The file order souce is configured to use a regular expression that ignores files that would not match the expression.
  • The incoming file has to be moved from the incoming directory until the end of the job chain. Two success and error nodes are added that move the file into different directories depending on the processing result.

Job: check_file_for_string

The following job implements checking of a file for a string:

Job Definition
<job  order="yes" stop_on_error="no">
    <script  language="shell">
@echo environment variable for return values: SCHEDULER_RETURN_VALUES=%SCHEDULER_RETURN_VALUES%

powershell.exe -Command "& { $match = Select-String -Path $env:SCHEDULER_PARAM_SCHEDULER_FILE_PATH -Pattern 'FF[0-9]*CA' | Select Matches; if ($match) { 'match=' + $match.Matches[0].Value | out-file -append $env:SCHEDULER_RETURN_VALUES -encoding Default; exit(0) } else { exit(1) } }"
    <run_time />


  • JobScheduler provides parameters as environment variables to shell jobs. Two variables are used:
    • SCHEDULER_PARAM_SCHEDULER_FILE_PATH: for a file order source JobScheduler provides this variable that contains the file path

    • SCHEDULER_RETURN_VALUES: JobScheduler provides this variable that contains the name of a temporary file. Shell jobs could write pairs of names and values to the file that would become parameters for subsequent jobs. 
      • The basic shell syntax is: echo my_param=my_value>>%SCHEDULER_RETURN_VALUES%
      • The PowerShell syntax is: 'my_param=my_value' | out-file -append $env:SCHEDULER_RETURN_VALUES
      • The PowerShell syntax used in the job is: 'match=' + $match.Matches[0].Value | out-file -append $env:SCHEDULER_RETURN_VALUES
        This syntax creates a parameter with the name match and the value from the matching string found in the incoming file.
  • PowerShell is used in order to parse the incoming file for a regular expression. If a match is found then it is added as a parameter with the name match for subsequent jobs.
    • The search string is configured as FF[0-9]*CA which matches any strings in the file that start with the characters FF followed by a number of any length and terminate with the characters CA.
  • PowerShell returns an exit code 0 if a match has been found and exit code 1 otherwise.
    • JobScheduler considers a job with exit code to be successful and would then continue with the next job node in the job chain and otherwise with the job node that is assigned to the error state.

Job: start_msaccess

The following job makes use of a previously found string match and would execute MS Access with a macro accordingly:

Job Definition
<job  order="yes" stop_on_error="no" title="Start MS Access">
    <script  language="shell">
@echo ... starting MS Access
@echo environment variable for match from previous job: SCHEDULER_PARAM_MATCH=%SCHEDULER_PARAM_MATCH%
@echo "C:\Program Files (x86)\Microsoft Office\OFFICE11\MSACCESS.exe" q:\companyX\%SCHEDULER_PARAM_MATCH%\U4284.mdb /x mkrU4284
    <run_time />


  • In the previous job a parameter match has been created that is provided by the environment variable %SCHEDULER_PARAM_MATCH% to the current job.
  • The job uses this variable to parameterize the launch of MS Access


  • No labels
Write a comment…