Internal variable for current directory
Posted: 2019-10-24, 17:09 UTC
This option can help users who need to run the programs in the elevated mode (As Administrator). Currently TC has a limitation:
This allows to run %comspec% with additional parameters, which change the starting directory to %userprofile% right upon start. So, CMD runs in %userprofile% directory, which in many cases is better than system32, but not yet always perfect.
I suppose that a special internal variable, resolved on-the-fly by TC before sending the command line to OS, could solve this problem completely.
Imagine, TC can define the internal variable, say, %COMMANDER_CURDIR% and we use it in the command line for CMD button:
We navigate to a particular directory, like C:\Program Files\Tools and call the command prompt as Admin right-clicking on the CMD button. This command is translated to %comspec% /k cd /d "C:\Program Files\Tools" and CMD opens its window in this location in Administrator mode.
Of course, this will work in user mode as well, like it is already implemented in TC by default.
For command processor CMD.exe this limitation (running from %windir%\system32) can be partially solved by using the special command line:Warning: Programs run as administrator will always start with the program directory as the start path, and environment variables (like %COMMANDER_PATH%) are NOT inherited from Total Commander, only those from the system.
Code: Select all
%comspec% /k cd /d %userprofile%
I suppose that a special internal variable, resolved on-the-fly by TC before sending the command line to OS, could solve this problem completely.
Imagine, TC can define the internal variable, say, %COMMANDER_CURDIR% and we use it in the command line for CMD button:
Code: Select all
%comspec% /k cd /d %COMMANDER_CURDIR%
Of course, this will work in user mode as well, like it is already implemented in TC by default.