Using Cmds Command-Line Syntax
The complete command-line syntax for Cmd.exe is
cmd [/a | /u] [/q] [/d] [/e:on | /e:off] [/f:on | /f:off] [/v:on | /v:off]
[[/s] [/c | /k] commandstring]
All arguments are optional. The available arguments are as follows:
- /A | /U This argument lets you specify the encoding system used for text that's piped to a file or other device. Use /A for ANSI or /U for Unicode. (The default is ANSI.)
- /Q The /Q argument starts Command Prompt with echo off. (With echo off, you don't need to include an @Echo Off line to suppress screen output in a batch program. To turn echo back on after starting Command Prompt with /Q, type echo on at the command prompt.)
- /D The /D argument disables execution of any AutoRun commands specified in the registry. (For more information, see the preceding section.)
- /E:on | /E:off The /E argument allows you to override the current registry settings that affect command extensions, which are enhancements to several internal commands; some extensions might be incompatible with last-century programs or work habits. Command extensions are enabled by default. To disable extensions by default, set the DWORD value EnableExtensions in HKLM\Software\Microsoft\ Command Processor to 0.
- /F:on | /F:off The /F argument allows you to override the current registry settings regarding file-name and folder-name completion.
- /V:on | /V:off The /V argument lets you enable or disable delayed variable expansion. With /V:on, for example, the variable !var! is expanded only when executed. The default is /V:off. To turn on delayed variable expansion as a default, add the DWORD value DelayedExpansion to HKLM\Software\Microsoft\Command Processor (for all users at the current machine) or HKCU\Software\Microsoft\ Command Processor (for the current user account only), and set DelayedExpansion to 1. (Delayed variable expansion is useful in conditional statements and loop constructs in batch programs. For more information, type help set at the command prompt.)
- /S [/C | /K] commandstring The alternative /C and /K arguments allow you to run
a command when Command Prompt starts-with /C terminating the session at the
command's completion and /K keeping it open. Including /S before /C or /K
affects the processing of quotation marks in commandstring.
If you do not include /S, and there are exactly two quotation marks in commandstring, and there are no "special" characters (&, <, >, (, ), @, ^, or |) in commandstring, and there are one or more white-space characters (spaces, tabs, or linefeeds, for example) between the two quotation marks, and commandstring is the name of an executable file, then Command Prompt preserves the two quotation characters.
If the foregoing conditions are not met and if the first character in commandstring is a quotation mark, Command Prompt strips the first and last quotation marks from commandstring.
In this tutorial:
- Working with the Command Prompt
- Starting and Ending a Command Prompt Session
- Easy ways to invoke administrator Command Prompt sessions
- Starting Command Prompt at a Particular Folder
- Strings with Spaces Need Quotes
- Cmd.exe vs. Command.com
- Commands Are Not Case Sensitive
- Starting Command Prompt and Running a Command
- Cmd.exe and Other Command Prompts
- Using AutoRun to Execute Commands When Command Prompt Starts
- Using Cmds Command-Line Syntax
- Using Commands
- Type /? for help
- Starting Programs
- Open Windows Explorer at the current Command Prompt folder
- Using File-Name and Folder-Name Completion
- Use a different completion character
- Using Wildcards
- Editing the Command Line
- Using Command Symbols
- The Redirection Symbols
- The Pipe Symbol
- The Command Combination Symbols
- Pausing or Canceling Commands
- Simplifying Command Entry with Doskey Macros
- DOSKEY Saves Typing
- System Variables Identify the Environment
- Viewing Environment Variables
- Modifying Environment Variables
- Predefined Environment Variables
- Customizing Command Prompt Windows
- Setting the Window Size and Position
- Setting the Window Size and Position Visually
- Selecting a Font
- Setting Colors
- Setting Other Options
- Copy and paste in the command prompt window
- Navigating from the command prompt
- Printing a list of filenames
- Commands Use Paths
- Identifying Executables
- Modifying the Path to Executables
- Modifying the Path with the GUI
- Changing the Current Path with CD
- Changing the Current Path with Windows Explorer
- Capturing the Output
- A Sampling of Commands
- Dir
- Copy
- XCopy
- SET
- NET USE
- SystemInfo
- DriverQuery
- Echo
- Advanced Shell Commands
- Creating a Batch File
- Scheduling a Batch File
- Creating Scheduled Tasks with a Script
- Using Windows PowerShell and the PowerShell ISE
- Windows PowerShell ISE
- PowerShell Commands
- Verbs and Nouns
- Sending Output to a Text File
- PowerShell Syntax
- Variables Created with a $ Symbol
- Comparison Operators
- Parentheses, Brackets, and Braces
- Running PowerShell Scripts
- PowerShell Execution Policy
- Changing the Execution Policy
- Looping
- Collections
- Creating a PowerShell Script
- Documenting Scripts
- Using PowerShell Commands
- Getting Help on PowerShell
- Using WMI_Cmdlets
- Getting Details on an Object
- Querying Information on Specific Objects
- Terminate Applications with Win32_process
- Formatting Output with the -f Format Operator
- Filtering the Output with the Where-Object Command
- Using the IF statement
- Using the Switch Statement
- Script Reusability