WINDOWS Jobs

Windows Jobs define Windows operating system processing steps to be carried out in a target system.

To Define Windows Job Properties

In the Start Parameters section, define how the Automic Automation for AIOps Job should start the job on the Windows target system.

  1. Define how to execute the script in Interpreter Type:

    • Batch

      The JCL contained on the Process page is executed as a Windows batch file.

    • Command (cmd.exe)

      The Windows CMD Shell contains a number of external commands that Windows supplies as separate executable files. Select the Command (cmd.exe) option to display the Command field and enter an external command. What you enter here is passed on to the Windows command line and executed.

      Note: For internal Windows commands such as dir, cd, or echo, you have the following options:

      • Use the Batch option instead
      • Call cmd.exe using /c to isolate and call a particular internal command

        Example: cmd.exe /c dir

    • Custom interpreter

      Administrator users can specify a custom interpreter in the INI file of the Windows Agent. Select this option to transfer the JCL contained on the Process as a file to that interpreter to process it.

    Best Practices

    Windows distinguishes between four program types:

    • Graphical User Interface programs
    • Console programs
    • Operating system commands, for example DIR or SET

    Start GUI and console programs from the command line to take advantage of the Automation Engine and retrieve the correct program exit code.

    OS commands can only be started using a BAT file. Check the return code after each command to react quickly to errors.

    Test the BAT file or the command line on the target system before starting the job through the Automation Engine. If possible, perform your tests with the user that will later execute the Automation Engine Windows Job.

  2. Specify the Working Directory in which the Job must run.

  3. Activate the Batch Mode: Log on as batch user to execute the job in batch mode. This is necessary when admin rights are required to execute programs and UAC (User Account Control) is activated on the target system. For more information, see User Account Control in WindowsUser Account Control (UAC) in Windows.

  4. In View Job on Desktop specify if you want to have the view that shows the execution of the job displayed. This is particularly useful for GUI programs because they sometimes display messages that require user intervention.

  5. Some jobs or programs in Windows start other child programs. The parent and the child run asynchronously. When the Automation Engine Windows Job starts one of these parent programs, it can happen that the parent ends while the child is still running. If this happens, the status of the Automation Engine Windows Job is also ended although some processes have not finished yet.

    Example

    A job contains a script with three command lines where the first one starts three sub-processes. When the three command lines have been successfully executed, the Windows Agent returns this information to the Automation Engine, which considers the Job as finished. As the sub-processes are running asynchronously, it can happen that they are not finished yet. The Automation Engine has no control over them and does not know about their status. This situation has the following consequences:

    • The information written to the reports is incorrect.
    • If the Job is started again while the sub-processes are still running, it will end abnormally.
    • If a process is canceled, its sub-process is not automatically canceled, which may cause an unwanted result.

    You can avoid these situations by connecting the Automation Engine Windows Job Object with its sub-processes within one Windows OS job object. The Windows OS job object is then in charge of signaling the end of the Automation Engine object when all its child processes have also ended and to also cancel all its child processes when the job is canceled.

    You can connect them using the options available in Use Windows OS Job Object:

    • Default setting from agent: Whether the Windows OS job object is used or not depends on the default setting specified in the INI file of the Windows Agent.
    • Yes: The Windows OS Job Object is used. The parent and child processed are connected.
    • No: The Windows OS Job Object is not used and no connection is established between parent and child processes.
  6. Save your changes

In the Job Report section, specify when to generate the reports and where to store them.

  1. Define where to store the report. You have two options. You can select one or both simultaneously:

    • Store to: Database means that when the Job has been executed, the process log available on the target system (on the Agent) is stored in the database.

      When a Job has been executed on an Agent, the corresponding report is stored on the Agent computer. After the Automation Engine has written this data to the database, the report is automatically deleted from the Agent computer. If it cannot be deleted due to an error, the deletion process is not repeated and an error message is displayed.

    • Store to: File means that the process log is stored as a file on the target system (Agent).
  2. Define when to generate the report

    You have two options:

    • Generate: Always means that the process log of the operating system is always written.

    • Generate: On error only means that the process log is written only when an error occurs. Example, when the job is canceled or aborted.

  3. To write an own Job report instead of the default one, select Scripted Report.
  4. Save your changes

See also: