As you’ve probably seen here on Lifewire and maybe other websites, Command Prompt commands, DOS commands, and even many run commands are described with all sorts of slashes, brackets, italics, etc. Once you know what all of those marks refer to, you can look at any command’s syntax and know right away what options are required and what options can be used with what other options.
Command Syntax Key
The following syntax key describes how each notation in a command’s syntax is to be used. Feel free to reference this as we walk through the three examples below the table. vol [drive:] The word vol is in bold, meaning that it should be taken literally. It’s also outside any brackets, meaning it’s required. We’ll take a look at brackets a few paragraphs down. Following vol is a space. Spaces in a command’s syntax are to be taken literally, so when you’re executing the vol command, you will need to put a space between vol and anything that might come next. Brackets indicate that whatever is contained inside them is optional—whatever is in there is not required for the command to function but might be something you want to use, depending on what you’re using the command for. Brackets are never to be taken literally so never include them when executing a command. Inside the brackets is the italicized word drive, followed by a colon in bold. Anything italicized is something you must supply, not take literally. In this case, a drive is referring to a drive letter, so you’ll want to supply a drive letter here. Just as with vol, since : is in bold, it should be typed as shown. Based on all of that information, here are some valid and invalid ways to execute the vol command and why: Valid: The vol command can be executed by itself because drive: is optional because it’s surrounded by brackets. Invalid: This time, the optional part of the command is being used, specifying drive as d, but the colon was forgotten. Remember, we know the colon accompanies the drive because it is included in the same set of brackets and we know it should be used literally because it’s bold. Invalid: The /p option wasn’t listed in the command syntax, so the vol command doesn’t run when using it. Valid: In this case, the optional drive: argument was used just as intended.
Example #2: Shutdown Command
The syntax listed here is for the shutdown command and is obviously much more complex than in the vol command example above. However, building on what you already know, there’s actually very little more to learn here: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f] [/m \computername] [/t xxx] [/d [p:|u:]xx:yy] [/c “comment”] Remember that items within brackets are always optional, items outside of brackets are always required, bold items and spaces are always literal, and italicized items are to be provided by you. The big new concept in this example is the vertical bar. Vertical bars within brackets indicate optional choices. So in the example above, you can, but don’t have to, choose to include one of the following options when executing a shutdown command: /i, /l, /s, /r, /g, /a, /p, /h, or /e. Like brackets, vertical bars exist to explain command syntax and are not to be taken literally. The shutdown command also has a nested option in [/d [p:|u:]xx:yy]—basically, an option within an option. Like with the vol command in the first example, here are some valid and invalid ways to use the shutdown command: Invalid: The /r and /s options can’t be used together. These vertical bars indicate choices, of which you can choose only one. Invalid: Using /s is perfectly fine but the use of p:0:0 is not because this option is available only with the /d option, which we forgot to use. The correct usage would have been shutdown /s /d p:0:0. Valid: All options were used correctly this time. The /r option was not used with any other choice within its set of brackets, and the /f and /t options were used as described in the syntax.
Example #3: Net Use Command
For our final example, let’s look at the net use command, one of the net commands. Its syntax is a little messy, so we’ve abbreviated it below to make explaining it a bit easier (see the full syntax here): net use [{devicename | *}] [\computername\sharename [{password | }]] [/persistent:{yes | no}] [/savecred] [/delete] The net use command has two instances of a new notation: the brace. A brace indicates that one, and only one, of the choices, separated by one or more vertical bars, is required. This is unlike the bracket with vertical bars that indicates optional choices. Let’s look at some valid and invalid uses of net use: Invalid: The first set of braces mean that you can specify a devicename or use the wildcard character * - you can’t do both. Either net use e: \server\files or net use * \server\files would have been valid ways to execute net use in this case. Valid: We correctly used several options in this execution of net use, including one nested option. We used the * when required to choose between it and specifying a devicename, we specified a share [source] on a server [appsvr01], and then chose to specify a {password} for that share, 1lovet0visitcanada, instead of forcing net use to prompt us for one {}. We also decided not to allow this new shared drive to be automatically reconnected next time we start the computer [/persistent:no]. Invalid: In this example, we chose to use the optional /persistent switch but forgot to include the colon next to it and also forgot to choose between the two required options, yes or no, between the braces. Executing net use /persistent:yes would have been a valid use of net use.