Skip to content

Job Automation (Old)

Job execution is normally requested through the Jobs Web API. This is very convenient for execution of jobs on demand. However, sometimes you want to automate job execution - for example executing a specific workflow once a day. One way to do this is to call the Job Executer from the Windows Task Scheduler.

Job Executer

The Job Executer is a console application that is published as a GitHub release. It can be downloaded from here.

To run the Job Executer with the minimum (required) arguments, use this syntax:

DHI.Services.Jobs.Executer -username {user} -password {password} -url {url} -connectionId {connectionId} -taskId {taskId}

Example:

DHI.Services.Jobs.Executer -username %user% -password %password% -url https://localhost:17510/ -connectionId wf -taskId myWorkflow

In addition to the required arguments, there are a number of optional arguments:

Argument Description
parametersFileName The given file must be a serialized dictionary e.g. {"MyKey1": "MyValue1", "MyKey2": "MyValue2"}
parameters Semicolon (';') separated pairs of {parameter}:{value}. If parameters are given, parametersFileName is ignored.
hostGroup If the hosts are grouped, this will force execution on one of the hosts in the given group.
priority Priority is an integer. A low number (e.g. 1) is equivalent to a high priority.
tag A tag (label) that is added to the job execution.

Using the Windows Task Scheduler

If using the Windows Task Scheduler, for the scheduled task Windows User Account, you can either specify the account that you are logged in as, or you can use the local SYSTEM account. Using the SYSTEM account has the advantage that when your Windows Domain Account is one day deleted (e.g: your contract with the client ends), the task will continue to execute.

When using the SYSTEM account, you do not need to check 'Run with highest privileges' for the task to execute successfully. Note that the 'Run whether user is logged in or not' is automatically selected after saving the task - you cannot select it yourself.