Can I use an environment variable as a button parameter?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Ahu_Lee
Junior Member
Junior Member
Posts: 37
Joined: 2016-08-09, 19:34 UTC
Location: Russia

Can I use an environment variable as a button parameter?

Post by *Ahu_Lee »

How can I use an environment variable instead of a particular full path as a button parameter?

For example, I'd like to have %APPDATA% instead of C:\Users\UserName\AppData\Roaming\ or %HOMEDRIVE%%HOMEPATH% instead of C:\Users\UserName etc

The above obviously won't work (otherwise I wouldn't ask this question), but I'm not sure why exactly. So, what would be the right way?

Thank you!
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Double all percent characters if you use environment variables in the parameter field of a button or the TC start menu. Strings like %C are special variables resolved by TC itself, see TC help for more details (press F1 in "Change button bar" dialog).

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Ahu_Lee
Junior Member
Junior Member
Posts: 37
Joined: 2016-08-09, 19:34 UTC
Location: Russia

Post by *Ahu_Lee »

Dalai wrote:Double all percent characters if you use environment variables in the parameter field of a button or the TC start menu. Strings like %C are special variables resolved by TC itself, see TC help for more details (press F1 in "Change button bar" dialog).

Regards
Dalai
I'm sorry l'm not sure what "Change button bar" dialog you are referring to. Can you tell me please, where exactly in the help file I can read about it? Or are there several of them? And unfortunately doubling percents doesn't do anything. And BTW, I'm using cd command (in case it's a wrong one for this).

Thank you.

UPDATE

Oh I see, you probably meant "change single button". Thanks.
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Ahu_Lee wrote:I'm sorry l'm not sure what "Change button bar" dialog you are referring to.
Right-click on free space on the button bar and select "Change...". But the "Change single button" dialog also works, of course.
And unfortunately doubling percents doesn't do anything. And BTW, I'm using cd command (in case it's a wrong one for this).
Make the button like this:

Code: Select all

TOTALCMD#BAR#DATA
cd %HOMEDRIVE%%HOMEPATH%

shell32.dll



-1
So, in essence, don't use the parameter field for the path you want to go to but put it right behind the cd command. The cd command is a command with parameters so it must be used like this.

You can copy the code above and right-click on some free space on you button bar and select "Paste" to create a new button from it.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2Ahu_Lee

It is only in the "Parameters:" field that you have to use double % signs - not in the "Command" field
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
DjobyDjoba
Junior Member
Junior Member
Posts: 52
Joined: 2006-10-23, 09:46 UTC

Post by *DjobyDjoba »

Sorry, same question. This doesn't work with %AppDATA%:

Command : C:\Program Files (x86)\Notepad++\notepad++.exe
Parameter : %APPDATA%\Roaming\ghisler\wincmd.ini
Path : C:\Program Files (x86)\Notepad++\

I've tried with %%AppDATA%% too.

Is it possible to use a variable in the parameter field, or do I have to enter the full path?

Thanks.
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

DjobyDjoba,
%APPDATA% already contains \Roaming\.
Also, yes, you have to use %%.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

2DjobyDjoba


Command : C:\Program Files (x86)\Notepad++\notepad++.exe %APPDATA%\ghisler\wincmd.ini
Parameter :
Path :







Also check in a DOS-Box the command

[face=comicsansms]set app[/face]

to see %AppData% already points to the Roaming folder.




- - - Update to show issue with NP++



NotePad++ Button does not work:
Comm: C:\Program Files\NotePad++ TEST\notepad++.exe
Param: %%AppData%%\GHISLER - Leerzeichen\WINCMD.INI



NotePad++ In DOS-Box works:
C:\>C:\Program Files\NotePad++ TEST\notepad++.exe %AppData%\GHISLER - Leerzeichen\WINCMD.INI



NotePad++ Button works:
Comm: C:\Program Files\NotePad++ TEST\notepad++.exe %AppData%\GHISLER - Leerzeichen\WINCMD.INI



Notepad2 Button works fine:
Comm: C:\Program Files\NotePad++ TEST\notepad2.exe
Param: %%AppData%%\GHISLER - Leerzeichen\WINCMD.INI




That was just an quick test with an very old NP++




 
 
Last edited by Stefan2 on 2017-08-12, 13:25 UTC, edited 1 time in total.
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

8)
C:\Program Files (x86)\Notepad++\notepad++.exe %COMMANDER_INI%

:P
Holger
Make our planet great again
DjobyDjoba
Junior Member
Junior Member
Posts: 52
Joined: 2006-10-23, 09:46 UTC

Post by *DjobyDjoba »

Thanks guys!
Hacker wrote:%APPDATA% already contains \Roaming\.
Oups... typo :oops:
Stefan2 wrote:- - - Update to show issue with NP++
NotePad++ Button does not work:
Comm: C:\Program Files\NotePad++ TEST\notepad++.exe
Param: %%AppData%%\GHISLER - Leerzeichen\WINCMD.INI
Indeed, issue with NP++ here! Doesn't like the parameter.



@HolgerK, Thanks, I will stick with this one!

Have a nice day!
Post Reply