Previous Topic: Windows JobsNext Topic: Command File Specifications in a Windows Job


Define a Windows Job

You can define a Windows job to schedule workload to run on a Windows computer. The job runs a Windows command file.

Note: To run these jobs, your system requires CA WA Agent for Windows.

Follow these steps:

  1. Open the Application that you want to add the job to in the Define perspective.

    The Application appears in the workspace.

  2. Select the Windows job from the System group in the Palette view, and drag the job to the workspace.

    The Windows icon appears on the Application workspace view.

  3. Right-click the Windows icon, and select Edit from the pop-up menu.

    The Basic page of the Windows dialog opens.

  4. Complete the following required fields as appropriate:
    Name

    Defines the name of the job that you want to schedule.

    Limits: 128 alphanumeric characters, plus the special characters commercial at (@), pound (#), dollar sign ($), underscore (_), square brackets ([]), brace brackets ({}), and percent sign (%) as a symbolic variable introducer character.

    Agent

    Specifies the name of the agent installed on the Windows computer or the name of the agent group where the job runs. You can use agent groups for load balancing or to run a job on all agents in a group.

    Note: The drop-down list displays all the agents that are defined in the Topology for the specified job type.

    Command to run

    Specifies the path to and name of the Windows command file the job runs.

    Note: You can also browse for the command file using the Command Browser or enter the command file name without the full path.

  5. (Optional) Specify the following additional information:
    Arguments to pass

    Defines the argument string of positional parameters to pass to the command file. Arguments can be numeric or alphabetic strings of data.

    Note: You must specify each parameter in the order it is expected in the command file, separating each parameter with a blank space. To pass a parameter containing spaces, enclose its value in double quotes.

    Example: "c:\Pay Data\salary.dat" "c:\Pay Data\benefits.dat"

    User ID

    Specifies the Windows user ID that runs the job. You are restricted to how you can access data on remote computers. To access restricted remote resources, you can run the job under a user ID that has access to those resources. The user must be defined in the Topology. This field supports the use of a namespace for a user that has more than one password. Contact your administrator for the user name defined in the Topology.

    Examples: Bob, Production:Bob

    Notes:

    • The drop-down list displays all the user IDs that are defined in the Topology for the specified agent. You must have at least Read access to the ADMIN.Network Topology permission to view this list.
    • You can specify a user ID only when the agent is running as a Windows service under the Local System account.
    Interactive job

    Indicates whether the Windows job runs in interactive mode. Interactive mode lets you view and interact with jobs that invoke Windows Terminal Services or user interface processes. To run a Windows job in interactive mode, the agent must run as a service and the administrator user ID must be defined in the Topology and specified in the job definition.

    Default: The job runs in batch mode

    Notes:

    • If the agent administrator sets the oscomponent.interactive parameter to true in the agentparm.txt file, the agent submits all Windows jobs in interactive mode, regardless of the setting in this field.
    • By default, the agent uses the default Windows shell explorer.exe. The agent administrator can specify an alternative Windows shell for interactive jobs by setting the oscomponent.shell parameter in the agentparm.txt file.
  6. Click OK.

    The Windows job is defined.

Example: Access a Windows Network Resource with Universal Naming Convention (UNC) and Share Names

CA Workload Automation DE and the agent support Windows UNC names and share names. A UNC name is the name of a file or other resource that begins with two backslashes (\\), indicating that it exists on a remote computer. A share name is an alias for the path in which the resource exists.

Suppose that the path c:\WINNT\Profiles\Visitor\Desktop\ has the share name MyDesktop. The command notify.cmd is in that path on the CYBNT server, and is accessed by the UNC name and share name in the job JOBC, which runs on the agent WINAGENT.

To access a Windows network resource with UNC and share names

  1. Enter the following information in the Basic page:
  2. Click OK.

Example: Use Administrative Authority to Access a Remote Windows Resource that is Not Shared

The agent service can log on to a remote Windows server as a user with administrative authority. The agent can then access remote resources using the share names C$ and ADMIN$, letting the agent access remote resources that are not marked as shared.

Suppose that drive C is accessed by an administrator over the network through the WINAGENT agent. The agent runs under the System Account option, and it runs the test Application in the c:\working directory on the CYBNT server. The directory c:\working is not a shared resource. The user admin1 is a valid user on both the local and remote computers, and belongs to the Administrators group.

To use administrative authority to access a remote Windows resource that is not shared

  1. Enter the following information in the Basic page:
  2. Click OK.

Example: Run cmd.exe

Suppose that you want the job COPYFILE to use the Windows command prompt (cmd.exe) to copy the file c:\env.txt to the test directory. To pass arguments to cmd.exe, you must enclose the argument in double quotes and precede the argument with the /C switch. The job runs on the default agent computer.

To run cmd.exe

  1. Enter the following information in the Basic page:
  2. Click OK.

Example: Pass Arguments to a Visual Basic Script

Suppose that you want the job VBS to pass three arguments (one, two, and thee) to the Visual Basic script located at D:\temp\vbs\params.vbs. To pass arguments to a Visual Basic script, specify the location of the Visual Basic script and its arguments in the Arguments to pass field. This job runs on the default agent computer.

To pass arguments to a Visual Basic Script

  1. Enter the following information in the Basic page:
  2. Click OK.

Example: Run a Windows Job on a Different Server Than Usual

Suppose that a company performs scheduled maintenance on its NT_TOR1 agent on the last Sunday of every other month. On that day, work that usually runs on NT_TOR1 must run on NT_TOR2.

The following conditional logic uses the month number to determine if a month is an even-numbered month. The % (remainder) operator divides the value of day by 2 and tests the remainder. If the remainder is 0, the agent name value is set to NT_TOR2.

The %IF statement for the job's Agent name field is as follows:

%IF(today('last sunday of month') && APPL._AMM%2 == 0,'NT_TOR2','NT_TOR1')

The APPL._AMM symbolic variable represents the number of the actual month. If today is the last Sunday of an even month, the logical expressions returns true, and the job runs on NT_TOR2. If today is not the last Sunday of an even month, the logical expression returns false, and the jobs runs on NT_TOR1.

Note: For more information about JavaScript expressions and built-in functions, see the Programming Guide.

Example: Run a Different Command File Depending on the Agent

Suppose that a job usually runs a payroll command file (c:\Windows\Payroll\payroll.exe) on the NT_TOR1 agent. Sometimes, the job runs under a different agent. In this case, the job needs to run an alternative command file (c:\Windows\Payroll\other_command.exe').

The %IF statement for the job's Command to run field is as follows:

%IF(WOB._Agent=='NT_TOR1','c:\\Windows\\Payroll\\payroll.exe',
'c:\\Windows\\Payroll\\other_command.exe')

Note: JavaScript treats backslashes (\) as special characters, so you must precede each backslash in file paths with another backslash.

The WOB._Agent symbolic variable represents the agent the job runs on.

Note: For more information about JavaScript expressions and built-in functions, see the Programming Guide.

Example: Run a Windows Job in Interactive Mode

This example runs a Windows job in interactive mode. The job opens the config.txt file in the Windows notepad application on the Windows desktop.

To run a Windows job in interactive mode

  1. Enter the following information in the Basic page:
  2. Select the Interactive job check box.
  3. Click OK.

More information:

Using a Namespace for a User that has Different Passwords

Windows Jobs

Run a Job on an Agent Group for Load Balancing

Run a Job on All Agents Defined in a Group