can we use environment variables in user command dialog?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
jmwap
Member
Member
Posts: 121
Joined: 2008-03-23, 12:40 UTC

can we use environment variables in user command dialog?

Post by *jmwap »

As TC usually allows me to use envvars everywhere, I am not sure if this is intended or not.

I am trying to create a user command, its parameter is a file. In the Parameters field, I select a file, with its absolute path, the command works fine.

If I change the path so that it contains an environment variable, the command does not work anymore (does nothing). Can't we use envvars there? Would be very useful

thanks
User avatar
petermad
Power Member
Power Member
Posts: 16116
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

You have to use double % characters in the Parameters field.

%TEMP% -> %%TEMP%%
License #524 (1994)
Danish Total Commander Translator
TC 11.55rc4 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1393a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
jmwap
Member
Member
Posts: 121
Joined: 2008-03-23, 12:40 UTC

Post by *jmwap »

petermad wrote:You have to use double % characters in the Parameters field.

%TEMP% -> %%TEMP%%
thanks, but at least in the Parameters field for the user command that is not working
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

jmwap, it will only work if program to be started supports envvars in parameters. You can't specify envvar to be expanded by TC in a Parameters field. However you can specify some parameters with envvars in Command field after path to program (w/o doubling % characters) and TC will expand them.
jmwap
Member
Member
Posts: 121
Joined: 2008-03-23, 12:40 UTC

Post by *jmwap »

MVV wrote:jmwap, it will only work if program to be started supports envvars in parameters. You can't specify envvar to be expanded by TC in a Parameters field. However you can specify some parameters with envvars in Command field after path to program (w/o doubling % characters) and TC will expand them.
understood, thanks. A pity as I use envvars everywhere but even without that, it is working great.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50865
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Try putting the parameters in the command field, e.g.
"c:\windows\notepad.exe" "%homedir%\filename.txt"

TC will resolve env vars in the command field, and placeholders in the parameters field.
Author of Total Commander
https://www.ghisler.com
jmwap
Member
Member
Posts: 121
Joined: 2008-03-23, 12:40 UTC

Post by *jmwap »

ghisler(Author) wrote:Try putting the parameters in the command field, e.g.
"c:\windows\notepad.exe" "%homedir%\filename.txt"

TC will resolve env vars in the command field, and placeholders in the parameters field.
in my case what I want to run is an TC internal command, so I tried:

OPENTABS %TEMP%\t.tab

but it does not work. In this case is not big deal for me as I can live with an absolute path anyway
thanks
User avatar
petermad
Power Member
Power Member
Posts: 16116
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2jmwap
OPENTABS %TEMP%\t.tab

but it does not work.
It works fine here - are you sure you remembered to put the t.tab file in the TEMP directory?
License #524 (1994)
Danish Total Commander Translator
TC 11.55rc4 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1393a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
jmwap
Member
Member
Posts: 121
Joined: 2008-03-23, 12:40 UTC

Post by *jmwap »

petermad wrote:2jmwap
OPENTABS %TEMP%\t.tab

but it does not work.
It works fine here - are you sure you remembered to put the t.tab file in the TEMP directory?
I stand corrected. Somehow I screwed up my test, it works perfectly!!!

thanks!
Post Reply