Hey folks,
Suppose you’re running an executable by typing its name into TC command line box at the bottom (e.g., “notepad”).
Is there any way to change the priority of directories being looked in when searching for that executable by name?
Canonical way would be the PATH environment variable, and TC looks into it, BUT for some reason it prioritizes the system directories like C:\Windows\System32\ even if they’re below in PATH.
Steps to reproduce:
0. Say we want to override ‘notepad’ with a different exe
1. Create a folder for the substitute EXE, C:\myexec
2. Place a substitute executable inside, e.g. copy C:\Windows\System32\cmd.exe to C:\myexec\notepad.exe
3. Add the folder to PATH env variable using sysdm.cpl, before the standard C:\Windows\System32
4. Reboot
5. Check the PATH variable using command line, should look like that
>set
Path=C:\myexec;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;etcetc...
6. Now, when executing "notepad" from a cmd.exe command line, command interpreter starts instead of notepad
7. But when executing "notepad" from Total Commander command line box, still C:\Windows\System32\notepad.exe runs
8. Nevertheless, if executing "notepad" with Shift-Enter from TC cmdline box, the intended command interpreter runs—so TC definitely got the PATH env variable
9. Also, if you rename C:\myexec\notepad.exe to notepad2.exe, TC runs that executable normally from cmdline box with "notepad2"—so TC honors the PATH variable, but for some reason seems to prioritize system folders regardless of PATH value.
Do you know any way to accomplish what I’m aiming for?
Executable search path priority in command line box
Moderators: Hacker, petermad, Stefan2, white
- chandragor
- Member
- Posts: 127
- Joined: 2005-06-01, 10:10 UTC
- Location: Italy
Re: Executable search path priority in command line box
I think that Mr.Ghisler uses the standard Windows APIs, and what Windows will execute is not trivial,
it might even depend on the API used.
For example, one of them is CreateProcessW which documents:
1. The directory from which the application loaded.
2. The current directory for the parent process.
3. The 32-bit Windows system directory.
4. The 16-bit Windows system directory.
5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6. The directories that are listed in the PATH environment variable.
it might even depend on the API used.
For example, one of them is CreateProcessW which documents:
1. The directory from which the application loaded.
2. The current directory for the parent process.
3. The 32-bit Windows system directory.
4. The 16-bit Windows system directory.
5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6. The directories that are listed in the PATH environment variable.
Happy owner of license #12422 since 1997
Re: Executable search path priority in command line box
Oh, you’re right. That’s the explanation.
Also while trying to figure out what API does TC use to execute commands from the box, i’ve stumbled upon a call to GetPrivateProfileString querying wincmd.ini for notepad= entry in [Alias] section.
So it turns out my use case is fulfilled using that (Configuration → Options → Misc → Redefine hotkeys → Alias)
Also while trying to figure out what API does TC use to execute commands from the box, i’ve stumbled upon a call to GetPrivateProfileString querying wincmd.ini for notepad= entry in [Alias] section.
So it turns out my use case is fulfilled using that (Configuration → Options → Misc → Redefine hotkeys → Alias)

Re: Executable search path priority in command line box
2vos
Have you tried this way?
6a. Press Win+R, type notepad, press Enter and report which exe is executed.
Have you tried this way?
6a. Press Win+R, type notepad, press Enter and report which exe is executed.
Andrzej P. Wozniak
Polish subforum moderator
Polish subforum moderator
Re: Executable search path priority in command line box
Usher, you’re right also, Win+R runs the system one as well.
Meanwhile Christian also replied to my support e-mail and advised to use HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths registry key that overrides path lookups. Worked perfectly
Meanwhile Christian also replied to my support e-mail and advised to use HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths registry key that overrides path lookups. Worked perfectly
Re: Executable search path priority in command line box
2vos
I was going to mention this registry key as well. Programs added there can run from TC command line but CMD console doesn't find them.
You can use short filenames as aliases, for example create key SAFP.exe with path to StandAloneFlashPlayer.exe as a default value.
I was going to mention this registry key as well. Programs added there can run from TC command line but CMD console doesn't find them.
You can use short filenames as aliases, for example create key SAFP.exe with path to StandAloneFlashPlayer.exe as a default value.
Andrzej P. Wozniak
Polish subforum moderator
Polish subforum moderator