CMD

RECENT NEWS

12/18/2015 - Hello! We're excited to announce that Mental Works Computing Software will soon be featuring

12/11/2015 - We're going to announce Dr.Batcher 3.0 Alpha with batch files debugger support soon. If you want to start...

News history...

TESTIMONIALS

Rob van der Woude:
"Mental Works Computing Software has created a nice tool for...

Andrew Jaritsyn:
“I used to write batch files with the help of Notepad, but...

Steve H.:
“This tool helped me to write some batch files in a couple...

More...

CMD

Starts the new instance of command line interpreter.

Syntax:

CMD [/c|/k] [/s] [/q] [/d] [/a|/u] [/t:{bf|f}] [/e:{on|off}] [/f:{on|off}] [/v:{on|off}] [Command]

/c – carries out the specified command and then terminates the interpreter.

/k ‑ carries out the specified command and then keeps the interpreter running.

/s – modifies the treatment of command after /c or /k.

/q – turns the echo off (quiet execution).

/d – ignore autorun commands from registry (HKLM or HKCU \Software\Microsoft\Command Processor\AutoRun).

/a – ANSI output.

/u – Unicode output.

/t – sets background (B) and/or foreground )(F) colors.

/e:on – enables command extensions.

/e:off – disables command extensions.

/f:on – enables the autocompletion of paths to files and folders entered in command prompt.

/f:off – disables the autocompletion of paths to files and folders entered in command prompt.

/v:on – enables delayed expansion of environment variables. It allows to write !var! instead of %var% to expand the variable at the execution time instead of input time.

/v:off ‑ disables delayed expansion of environment variables.

Command – the command you want to carry out.

Usage:

Running without parameters CMD displays the version of operating system and copyright message.

You can run multiple commands connected with && if they are surrounded by quotes.

If you use /c or /k keys, the remainder of the string after them is processed as the command line, where the following logic is used to process the quotes.

Quote characters are preserved if all of these conditions are met:

  1. You do not use /s switch;
  2. You use exactly two quote characters;
  3. You do not use special characters (&<>()@^|) between the quotes;
  4. There is at least one space character between the quotes;
  5. The string between the quotes is the name of an executable file.

Otherwise the interpreter strips the first quote character and the last quote character preserving any text after the last one.

If /d switch is not used, CMD looks at registry for HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun\REG_SZ and HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun\REG_EXPAND_SZ. If one or both of these keys exist, they are executed before all other variables.

Command extensions enable the following commands: assoc, call, chdir/cd, color, del/erase, endlocal, for, ftype, goto, if, mkdir/md, popd, prompt, pushd, set, setlocal,  shift, start. In Windows command extensions are enabled by default.

Delayed variable expansion is not enabled by default.

File and directory completion is not enabled by default. You are to use quotes to make the completion correctly process the names of files and folders with spaces. Use Ctrl+D for directory name completion and Ctrl+F for file name completion.

 

Subscribe batch files programming newsletter (no spam):

Subscribe

Unsubscribe