A task action is the work that is performed when the task is run. A task can have a single action or a maximum of 32 actions. Each action contains settings that determine how the action is performed. A task's actions are displayed on the Actions tab of the Task Properties or Create Task dialog box. When multiple actions are specified, they are executed in sequential order starting with the action at the top of the list in the Actions tab and ending with the action at the bottom of the list. You can change the order in which the actions are executed by selecting an action and clicking on the up or down arrow button to move the action in the list.

The following list contains a description of each action and the action settings.

  • Start a program

    This action starts a program or script. In the Program/script text box, enter the name of the program or script you want to start. If the program or script takes command line arguments, you can supply these arguments in the Add arguments (optional) text box. In the Start in (optional) text box, you can specify the working directory for the command line that executes the program or script. This should be either the path to the program or script file or the path to the files that are used by the executable file.

  • Send an e-mail

    This action sends an e-mail when a task is triggered. In the action settings you specify the e-mail address that the e-mail is from, the e-mail address that the mail will be sent to, the subject of the e-mail, the text in the e-mail message, and optional e-mail attachments. You must also specify the SMTP server that you use to send e-mail from.

    Note

    This action is not available for tasks configured for Windows Server 2003, Windows XP, or Windows 2000.

  • Display a message

    This action shows a message box with a specified message and title. The action settings specify the text for the message box title and the text in the message. This action will only launch if the Run only if user is logged on security option is selected in the General tab of the Task Properties or Create Task dialog box.

    Note

    This action is not available for tasks configured for Windows Server 2003, Windows XP, or Windows 2000.

Starting a program

If an action starts a program when a task is triggered, then you need to enter the name of the program or script and the command-line arguments needed to run the program or script. The following list contains commonly used programs that an action can run. To display more information about each program and the available arguments for each program, type the program name followed by /? at a command prompt.

Note

A program might require elevated privileges to run correctly. For information about how to specify the security context for a task, see Task Security Context.

 

Name (Localizable) Program/script Arguments

Run a script

cscript.exe

Note

To run a script, you can specify the name of the script file with no arguments instead of specifying cscript.exe, and the default script host is used to run the script.

<script file>

Copy a file

robocopy

<source file> <destination file>

Start a service

net

start <service name>

Stop a service

net

stop <service name>

Shut down

shutdown

-s

Restart

shutdown

-r

Log off

shutdown

-l

Disk cleanup

cleanmgr

/sagerun

Defragment a disk

defrag

<drive letter>

Check a disk

chkdsk

<drive letter>

Map a drive

net

use <drive letter> <network path>

Connect to a dial-up network

rasdial

<entry name>

Disconnect from a dial-up network

rasdial

<entry name> /disconnect

Archive an event log

wevtutil

Note

This program is not available on operating systems prior to Windows Vista®.

al <log path>

Display a web page

Any installed browser

<URL>

Additional references