Command line: Don't automatically add "cmd /c" if the command being executed is cmd
Posted: 2026-05-29, 01:33 UTC
Commands that are run on Total Commander's command line are generally executed "directly", but sometimes via "%comspec% /c <command>".
Since the earliest Windows Commander versions, "%comspec% /c " is added for these commands:
dir
ren
del
copy
type
date
time
And also when the redirection symbols are used on the command line:
|
<
>
So because "dir" is in the list above, running this command works:
Although Total Commander is picky and you need to use a space behind "dir" here and no other standard delimiters (comma, semicolon, equal sign) are allowed.
Because "echo" is not in the list above, running this command results in a file not found message:
The user can add "cmd /c" to make it work:
Or by using a redirection symbol in the command:
So Total Commander has a smart implementation that adds "cmd.exe /c " when a redirection symbol is used.
However, the implementation is not smart enough to omit adding "cmd.exe /c " when the user already added "cmd.exe /c" himself. So when you run this command:
this is the command that actually ends up being executed:
My suggestion is to make the implementation a little smarter so that "%comspec% /c " is not added when the command being executed is %comspec%.
Since the earliest Windows Commander versions, "%comspec% /c " is added for these commands:
dir
ren
del
copy
type
date
time
And also when the redirection symbols are used on the command line:
|
<
>
So because "dir" is in the list above, running this command works:
Code: Select all
dir & pause
Because "echo" is not in the list above, running this command results in a file not found message:
Code: Select all
echo ==Bare directory list== & dir /b & pause
Code: Select all
cmd /c echo ==Bare directory list== & dir /b & pause
Code: Select all
echo ==Bare directory list== & dir /b & pause & rem|
However, the implementation is not smart enough to omit adding "cmd.exe /c " when the user already added "cmd.exe /c" himself. So when you run this command:
Code: Select all
cmd.exe /c echo Writing bare directory list to file.. & (echo ==Bare directory list== & dir /b/s) > dirlist.txt & echo. & pause
Code: Select all
c:\WINDOWS\system32\cmd.exe /C cmd.exe /c echo Writing bare directory list to file.. & (echo ==Bare directory list== & dir /b/s) > dirlist.txt & echo. & pause