Every shell command has the same basic syntax rule.
An optional section with examples using the command, such as: sample /a Test! sample off
Every shell command has the same basic syntax rule.
A command consists of a command name followed by any required or optional arguments. Arguments include parameters used to pass information needed by the command and switches used to control the way the command works as well as modifiers that change the behavior of a switch. Command names and arguments are always separated by spaces. Here is an example: dir /s c:\data In this example, dir is the command that you want to execute, /s is a command switch, and c:\data is a command parameter. As you work with commands, you'll notice that some commands have only one style of use (or syntax), while others have multiple uses (or syntaxes). Command Redirection Normally, shell commands take input from the parameters and switches specified when the commands are called and send their output to the standard console window.
If you want to change this behavior, you can redirect input and output if necessary. For example, you can take input from a different source or send output to a file or other output device. Redirection techniques you can use and their syntaxes include: Most shell commands generate output that can be redirected. You redirect command output using the pipe symbol (|), such as: ftype | sort | more The < redirection symbol enables you to specify a file as input for a command, such as: sort < details.txt The > redirection symbol sends command output to a file overwriting any existing data, such as: ver > os.txt To append output to an existing, use the >> redirection symbol, such as: pathping >> pingdata.txt Redirecting Errors Normally, errors are output to the command shell. If necessary, you can redirect error output to a file using the 2> redirection symbol, such as: netstat r 2> errors.txt To redirect standard error to the same destination as command output, use the 2>&1 redirection symbol, such as: netstat r > data.txt 2>&1 You can also send output to devices, such as a printer. Here is an example: ipconfig > lpt1 I/O devices you can use with the command shell include: Chaining and Grouping Commands You can chain commands together or have certain commands execute only if earlier commands succeed (or fail).
When you use multiple commands together, you reate a compound command. The syntax for compound commands is:
You run Windows scripts using a scripting host. The scripting hosts are:
wscript wscript is used when you execute scripts from the desktop.
cscript cscript is a command-line scripting host. All output from cscript is displayed at the Windows command prompt unless you specify otherwise. You can run scripts using any of the following techniques: Start Windows Explorer, browse until you find a script, then double-click on the script. Double-click on a desktop shortcut to a script.
Enter a script's full name and path at the Run command on the Start Menu. At the command-line prompt by typing either wscript or cscript followed by the script's full name The command-line syntax for cscript is: cscript [host_options] [script_name] [script_args] Here, host_options Sets options for cscript, script_name identifies the script to run, and script_args are arguments to pass in to the script, such as: cscript C:\Scripts\checkdrvs.vbs The arguments for cscript are:
In Windows XP, you can schedule commands to run using the Scheduled Task Wizard and the AT utility. With the Scheduled Task Wizard, you use a graphical interface to configure when and how tasks should run. With AT, you enter commands at the command prompt. While both features are useful, AT makes it really easy to schedule tasks anywhere on the network and you dont have to log on to remote systems.
Scheduling Essentials With AT, tasks are scheduled using a 24-hour clock where 00:00 is midnight and 12:00 is noon.
Scheduling Essentials With AT, tasks are scheduled using a 24-hour clock where 00:00 is midnight and 12:00 is noon.
With this in mind, if you wanted to schedule a task to run at 3:00 AM, you'd enter the time as 03:00. AT can run any commands that you would normally type at the command prompt. However, you should know that AT doesn't automatically load the command interpreter before running built-in command-line utilities, such as copy, del and move. So if you want to run built-in commands, you'll need to explicitly load the command shell (cmd.exe) at the beginning of a command. For example, if you wanted to run a move command every weekday at 3:00 AM you would need to enter the following command: AT 03:00 /every:M,T,W,Th,F "cmd /c move c:\work\old\*.* c:\oldwork\save" You don't have to start an instance of the command interpreter with other programs and utilities that have separate executables. For example, this means you could run NTBACKUP without having to load the command shell.
However, the executable must be in a directory accessible along the command path. If the executable isn't accessible, you'll need to provide the full path information. For example, if you wanted to run a cleanup script every other weekday at 5:00 AM, you could enter the command: AT 05:00 /every:M,W,F cleanup.bat When you use the