TC 11.57 Right-click "Run as administrator" on .cmd file will fail if filename contains ()
Moderators: petermad, Stefan2, Hacker
TC 11.57 Right-click "Run as administrator" on .cmd file will fail if filename contains ()
Total Commander 11.57 will fail to "Run as Administrator" .CMD or .BAT files that contain brackets, for example:
Test(test).cmd will fail executing while Test.cmd will not.
It does not matter what file contains, only how it is named.
Test(test).cmd will fail executing while Test.cmd will not.
It does not matter what file contains, only how it is named.
- ghisler(Author)
- Site Admin

- Posts: 53149
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: TC 11.57 Right-click "Run as administrator" on .cmd file will fail if filename contains ()
This seems to be a Windows bug, so I cannot fix it. Try the same in Explorer (right click, Run as Administrator).
Running the command
*"Test(test).cmd"
with Shift+Enter from the command line seems to work, though.
Running the command
*"Test(test).cmd"
with Shift+Enter from the command line seems to work, though.
Moderator message from: ghisler(Author) » 2026-06-04, 08:06 UTC
Moved to will not be changed
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: TC 11.57 Right-click "Run as administrator" on .cmd file will fail if filename contains ()
Isn't that dependent on whether or not the path contains a space or not?
The fun part comes in when you also create a file named "Test^(test^).cmd" and when you run this file as administrator. Then it can happen that the wrong file is executed
Create these batch files in a path that does not contain spaces:
Test(test).cmd
Test^(test^).cmd
When running "Test^(test^).cmd" as administrator, "Test(test).cmd" is executed instead.
Let's look in the registry and see what happens.
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cmdfile\shell\runas\command
The fun part comes in when you also create a file named "Test^(test^).cmd" and when you run this file as administrator. Then it can happen that the wrong file is executed
Create these batch files in a path that does not contain spaces:
Test(test).cmd
Code: Select all
@echo off
echo Batch file started: "Test(test).cmd"
pause
Code: Select all
@echo off
echo Batch file started: "Test^(test^).cmd"
pause
Let's look in the registry and see what happens.
- HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cmdfile\shell\open\command
Seems to cause execution of:
Code: Select all
"%1" %*Code: Select all
c:\windows\System32\cmd.exe /C ""%1" %*" - HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cmdfile\shell\runas\command
Seems to cause execution of:
Code: Select all
%SystemRoot%\System32\cmd.exe /C "%1" %*Code: Select all
"c:\windows\System32\cmd.exe" /C "%1" %*
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cmdfile\shell\runas\command
Code: Select all
%SystemRoot%\System32\cmd.exe /C ""%1" %*"- ghisler(Author)
- Site Admin

- Posts: 53149
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: TC 11.57 Right-click "Run as administrator" on .cmd file will fail if filename contains ()
Maybe use /S/C instead of /C ?
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: TC 11.57 Right-click "Run as administrator" on .cmd file will fail if filename contains ()
Adding the quotes to the registry value (as described) solves it. There's no need to add /S in that case because the outer quotes will be stripped anyway when there are more than 1 pair of quotes. As mentioned, that's how Microsoft is doing it when running a batch file non-elevated.

