The Scheduled Task Wizard is great for having specific programs run at regular intervals without intervention, but most programs have specific parameters that you can set that change how the program is run. For example, if you run the defrag utility, you can include a -a parameter after the command to cause the utility to run in analysis mode only. Using these parameters, you can control more precisely the type of command that is run.
There are several ways to execute a program with the appropriate parameters attached, including entering the flags in the Run field of the Properties dialog box for the scheduled task, entering the command into the Start, Run dialog box or in the Command Prompt interface, or creating a separate batch file. This last method is particularly useful. By creating a batch file, you can define specific program commands or execute multiple commands at once.
Before you can use a program parameter, you need to find the specific parameters for the program that you plan to execute. You can often find these parameters within the Help file for the various utilities, as shown for the Defrag utility in Figure 39.14.
Figure 39.14: You can find parameters for a specific program within the Help file.
If you have the Command Prompt interface open, you can also get a program's parameters by typing the
Figure 39.15: You can view program parameters by typing the /? parameter after the program's name.
Figure 39.16: You can add parameters to the end of the execution command in the Run field of the task's Properties dialog box.
You can add multiple parameters to an execution command by separating them with a space.
If you select the Start Run menu, the Run dialog box, shown in Figure 39.17 opens. Using this dialog box you can enter a program to execute along with its parameters. It is important to have the exact program name typed correctly.
Figure 39.17: You can add parameters to the end of the execution command in the Run dialog box.
You can also execute program commands and parameters in the Command Prompt interface. This interface hearkens back to the DOS days when all instructions were run using text commands.
The Command Prompt interface opens using the Start All Programs Accessories Command Prompt menu. You can enter DOS commands directly into the interface; you can get a list of DOS commands by entering the command help in the interface. You can perform all of these textual commands within Windows using the various utilities, but the textual commands are helpful when composing batch files.
Issuing program commands in the Run dialog box or the Command Prompt runs the command a single time only, but if you enter the commands into a text file and save them as a batch file that can be accessed as a scheduled task, then you have the power to run specific custom
A batch file is simply a text file saved using the .bat file extension. These text files include any textual commands that can be entered in the Command Prompt interface, including program execution commands with parameters and any DOS textual commands. Once you've created the batch file, you can use the Scheduled Task Wizard to make the file into a scheduled task.
Be sure to test your batch file before making it a scheduled task.
To create a batch file as a scheduled task, follow these steps:
Select the Start All Programs Accessories Notepad menu command to open Notepad.
Enter the commands to execute in the Notepad window such as defrag /a /v.
Save the file to the hard drive using the .bat extension.
Locate the saved .bat file and execute it to test its behavior. If the batch file has any trouble, reopen the file and correct the problems before saving it again.
Once the file is working fine, use the Scheduled Task Wizard to create a new scheduled task that runs the batch file.