Why the system variable %username% does not work?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
PiotrMP6
Junior Member
Junior Member
Posts: 10
Joined: 2021-06-18, 05:49 UTC

Why the system variable %username% does not work?

Post by *PiotrMP6 »

Hi

Why the system variable %username% does not work?

ex

[right]
path=C:\Users\%username%\Work
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Why the system variable %username% does not work?

Post by *Horst.Epp »

Works here in directory hotlist
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Why the system variable %username% does not work?

Post by *Stefan2 »

PiotrMP6 wrote: 2021-07-20, 11:28 UTC Hi

Why the system variable %username% does not work?

ex

[right]
path=C:\Users\%username%\Work


What do you try to do?

Me think that setting is written by TC itself on saving the settings.



 
User avatar
norfie²
Power Member
Power Member
Posts: 986
Joined: 2006-02-10, 07:27 UTC

Re: Why the system variable %username% does not work?

Post by *norfie² »

It doesn't work because it is not implemented in [right] section of wincmd.ini.
"War is evil, in so far as it makes more bad people than it takes away."
Immanuel Kant in "Perpetual Peace"
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Why the system variable %username% does not work?

Post by *Horst.Epp »

norfie² wrote: 2021-07-21, 07:50 UTC It doesn't work because it is not implemented in [right] section of wincmd.ini.
Who edits the [Left] or [Right] entries by hand, for what reason ?
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
norfie²
Power Member
Power Member
Posts: 986
Joined: 2006-02-10, 07:27 UTC

Re: Why the system variable %username% does not work?

Post by *norfie² »

Who edits the [Left] or [Right] entries by hand, for what reason ?
It could be useful if the option "Save on exit - Directories"is disabled and one prefer to start with the %username% folder.
"War is evil, in so far as it makes more bad people than it takes away."
Immanuel Kant in "Perpetual Peace"
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Why the system variable %username% does not work?

Post by *petermad »

You can use:

Code: Select all

[right]
path=::{59031a47-3f72-44a7-89c5-5595fe6b30ee}
to start in the virtual folder \\Username\ which of course is not quite the same as the physical forder c:\Users\Username\
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Why the system variable %username% does not work?

Post by *Stefan2 »

Horst.Epp wrote: 2021-07-21, 08:51 UTC Who edits the [Left] or [Right] entries by hand, for what reason ?


For example for to copy a ready made wincmd.ini to other users for the very first start, or for a live-CD (Windows PE, like BartPE)

There are more possibilities one could suppose.





 
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Why the system variable %username% does not work?

Post by *Horst.Epp »

Stefan2 wrote: 2021-07-21, 13:38 UTC
Horst.Epp wrote: 2021-07-21, 08:51 UTC Who edits the [Left] or [Right] entries by hand, for what reason ?
For example for to copy a ready made wincmd.ini to other users for the very first start, or for a live-CD (Windows PE, like BartPE)
 
Only for the first start of a new user I see a usage.
I used BartPE bevor WinPE for years and there is no username or login necessary for both.
I just copy my portable TC installation onto the CD and use it without problems.
Now the same for WinPE with USB sticks as media.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Why the system variable %username% does not work?

Post by *ghisler(Author) »

The reason is that a directory name like C:\Users\%username%\Work is perfectly allowed. So in path fields saved by TC, environment variables will not be replaced unless the path itself is invalid. For example, you can use
right=%userprofile%\Work
Because it's not a valid path with % at the start.

If Total Commander is installed on C, you can use somthing like this:
path=%commander_drive%\users\%username%\Work
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Why the system variable %username% does not work?

Post by *petermad »

2ghisler(Author)
For example, you can use
right=%userprofile%\Work
Except it will not work with IgnoreDirErrors=1
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Why the system variable %username% does not work?

Post by *petermad »

2ghisler(Author)
petermad wrote:Except it will not work with IgnoreDirErrors=1
Can you confirm this finding?
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Why the system variable %username% does not work?

Post by *ghisler(Author) »

Yes, this happens because TC only tries to replace the environment variable when an error occurs. The problem here is that the function used also handles relative directories, which can contain the % character too.
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Why the system variable %username% does not work?

Post by *petermad »

2ghisler(Author)
Could that be fixed eventually with a third option:
2: As 1 but switch to directories that starts with (or better contains) an environment variable.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Why the system variable %username% does not work?

Post by *ghisler(Author) »

"Starts with" should be possible, but "contains" will be a problem because a directory can actually be named %variablename%.
Author of Total Commander
https://www.ghisler.com
Post Reply