CMD - Exe (Command Shell) - Windows CMD
CMD - Exe (Command Shell) - Windows CMD
com
CMD.exe
Start a new CMD shell and (optionally) run a command/executable program.
Syntax
CMD [charset] [options]
At the command prompt Ctrl-D gives folder name completion and Ctrl-F gives File and folder name completion.
These key-strokes will display the first matching path. Thereafter, repeated pressing of the same control key will cycle through
the list of matching paths. Pressing SHIFT with the control key will move through the list backwards.
/V:OFF
Disable delayed environment expansion.
Delayed Environment expansion can also be set with SETLOCAL
If /C or /K is specified, then the remainder of the command line is processed as an immediate command in the new shell. Multiple
commands separated by the command separator '&' or '&&' are accepted if surrounded by quotes.
In Windows Explorer, you can type "cmd" in the address bar to open a prompt at the current location.
For more detail about the CMD shell: QuickEdit, handing quotes, max line length etc, see the CMD Syntax page.
https://ss64.com/nt/cmd.html 1/3
1/6/2023 CMD.exe (Command Shell) - Windows CMD - SS64.com
If you start a second nested CMD shell (or PowerShell), this will be added to the TITLE of the CMD/terminal window, when you EXIT back
to the initial shell, the Title will also revert making it possible to track how many nested shells you have open.
ErrorLevel
CMD /C will return an errorlevel, for example CMD /c dir Z: where the drive Z: does not exist, will return %errorlevel% = 1 to the
calling CMD shell.
Inheritance
A new CMD.exe session can be instantiated in several ways, explicitly starting a new CMD session from an existing CMD shell,
CALLing a batch file or implicit instantiation caused by piping a command or running a FOR /F command.
In all these cases, only the environment variable values are inherited by the new CMD session. Delayed expansion state, Command
extension state and Echo state will all revert back to the default state based on the registry.
For more detail on inheritance and expansion see this StackOverflow thread.
Command Extensions
Disabling Command Extensions may affect the operation of CMD's internal commands, and will also remove most dynamic/volatile
environment variables ( %CD% %DATE% %TIME% %RANDOM% %ERRORLEVEL% %CMDEXTVERSION% %CMDCMDLINE%
%HIGHESTNUMANODENUMBER% )
Examples
https://ss64.com/nt/cmd.html 2/3
1/6/2023 CMD.exe (Command Shell) - Windows CMD - SS64.com
Spaces in Program Path + parameters:
CMD /c ""c:\Program Files\demo.cmd"" Parameter1 Param2
CMD will strip the outer quotes if there is a double quote at the start and end so you can also cheat and write the above as:
CMD /k @"c:\batch files\demo.cmd" "Parameter 1 with space" "Parameter2 with space"
Related commands
https://ss64.com/nt/cmd.html 3/3