add hash class extended command parameters for Button Bar

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
thomasmo
Junior Member
Junior Member
Posts: 81
Joined: 2013-11-04, 01:31 UTC

add hash class extended command parameters for Button Bar

Post by *thomasmo »

It is recommended to add hash class extended command parameters, for example, I need to set the parameter "--disk-cache-dir =%TEMP%\ChromiumCache%RANDOM%" for the Chromium class browsers
User avatar
petermad
Power Member
Power Member
Posts: 14796
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: add hash class extended command parameters for Button Bar

Post by *petermad »

And what prevents you from doing that in currrent TC?

You do know that if you want to put environment variables in the "Parameters:" field of a button you have to double the %-signs - like:

Code: Select all

--disk-cache-dir=%%TEMP%%\ChromiumCache%%RANDOM%%
If you use the parameter in the "Command:" field you just use ordinary single %-signs.
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.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
thomasmo
Junior Member
Junior Member
Posts: 81
Joined: 2013-11-04, 01:31 UTC

Re: add hash class extended command parameters for Button Bar

Post by *thomasmo »

petermad wrote: 2020-04-18, 20:24 UTC And what prevents you from doing that in currrent TC?

You do know that if you want to put environment variables in the "Parameters:" field of a button you have to double the %-signs - like:

Code: Select all

--disk-cache-dir=%%TEMP%%\ChromiumCache%%RANDOM%%
If you use the parameter in the "Command:" field you just use ordinary single %-signs.
I'd try both like "D:\ChromiumCache%%RANDOM%%" & "D:\ChromiumCache%RANDOM%", but I got the folder "D:\ChromiumCache%RANDOM%" twice
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: add hash class extended command parameters for Button Bar

Post by *ghisler(Author) »

If you put environment variables in double % signs in the parameters field, they will NOT be resolved by Total Commander. They will be passed with single % signs to the target application. It's then the duty of the target application to resolve them.

If you want to resolve environment variables in Total Commander, you need to put them in the "command" field. This field also accepts command line paramters as long as you properly quote names containing spaces.
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 14796
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: add hash class extended command parameters for Button Bar

Post by *petermad »

2thomasmo
I'd try both like "D:\ChromiumCache%%RANDOM%%" & "D:\ChromiumCache%RANDOM%", but I got the folder "D:\ChromiumCache%RANDOM%" twice
But did you use "D:\ChromiumCache%RANDOM%" in the Command field?

There are three options:
Either
Command: drive:path\yourprogram --disk-cache-dir=%TEMP%\ChromiumCache%RANDOM%

OR:
Command: %COMSPEC% /C start "" "drive:path\yourprogram"
Parameter: --disk-cache-dir=%%TEMP%%\ChromiumCache%%RANDOM%%

OR:
Command: %COMSPEC% /C
Parameter: start "" "drive:path\yourprogram" --disk-cache-dir=%%TEMP%%\ChromiumCache%%RANDOM%%
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.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
thomasmolover
Member
Member
Posts: 167
Joined: 2016-12-12, 01:32 UTC

Re: add hash class extended command parameters for Button Bar

Post by *thomasmolover »

petermad wrote: 2020-04-20, 12:48 UTC 2thomasmo
I'd try both like "D:\ChromiumCache%%RANDOM%%" & "D:\ChromiumCache%RANDOM%", but I got the folder "D:\ChromiumCache%RANDOM%" twice
But did you use "D:\ChromiumCache%RANDOM%" in the Command field?

There are three options:
Either
Command: drive:path\yourprogram --disk-cache-dir=%TEMP%\ChromiumCache%RANDOM%

OR:
Command: %COMSPEC% /C start "" "drive:path\yourprogram"
Parameter: --disk-cache-dir=%%TEMP%%\ChromiumCache%%RANDOM%%

OR:
Command: %COMSPEC% /C
Parameter: start "" "drive:path\yourprogram" --disk-cache-dir=%%TEMP%%\ChromiumCache%%RANDOM%%
thank you

I just would not want to a commander windows flash beforce launch app either use some app like AHK to do it
User avatar
thomasmolover
Member
Member
Posts: 167
Joined: 2016-12-12, 01:32 UTC

Re: add hash class extended command parameters for Button Bar

Post by *thomasmolover »

ghisler(Author) wrote: 2020-04-19, 08:14 UTC If you put environment variables in double % signs in the parameters field, they will NOT be resolved by Total Commander. They will be passed with single % signs to the target application. It's then the duty of the target application to resolve them.

If you want to resolve environment variables in Total Commander, you need to put them in the "command" field. This field also accepts command line paramters as long as you properly quote names containing spaces.
I'd put the %random% in "command" field, but it pass a "%" symbol to the commander but not get environment variables.

I test the command in AHK like this

Code: Select all

for n, param in A_Args
{
    MsgBox Parameter number %n% is %param%.
}
ExitApp
and compiled it to test.exe and put it to the TC bar

so I test command:
test.exe %random%

If I put "%random%" in command field, it shown "%random%"

if put "%random%" in parameter field, "%r" get the filename with focus in the target window, and "andom" follow it, just like "tempandom" etc.
User avatar
Stefan2
Power Member
Power Member
Posts: 4155
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: add hash class extended command parameters for Button Bar

Post by *Stefan2 »

2thomasmolover
ghisler(Author) wrote: 2020-04-19, 08:14 UTC If you put environment variables in double % signs in the parameters field,
they will NOT be resolved by Total Commander.
They will be passed with single % signs to the target application.
It's then the duty of the target application to resolve them.
It's then the duty of the target application to resolve them.


Use an leading ? question sign in the Parameters box to see what TC will pass to AHK.


COMMAND: xxxxx\AHK\AutoHotkey.exe xxxx\ShowParameters.ahk
PARAMETERS: ?%%TEMP%% ### %%RANDOM%%
>>>?-DIALOG Shows: %TEMP% ### %RANDOM%
>>>OUTPUT: nothing (probably %...% are variables in AHK, and that non-existing vars in the script result in empty string)

Also passing %var% to an VBS script for example
For i = 0 to WScript.Arguments.Count -1
      MsgBox WScript.Arguments.Item(i)

will not automatically expand the vars, because VBS doesn't know what you want from it.
You can pass %var%s and then handle (expand) them inside the script by using VBS functions to do that.


With CMD it will work:
COMMAND: cmd /k
PARAMETERS: ?Echo %%TEMP%% # # # %%RANDOM%%
>>>?-DIALOG Shows: Echo %TEMP% # # # %RANDOM%
>>>OUTPUT: C:\Users\Stefan2Einer\AppData\Local\Temp # # # 20050


So your program can not handle environment variables (at least not that way).
Solution: Just call a ahk script from your button, use there the EnvVars you want (or utilize AHK functions) and call your application from there.



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

Re: add hash class extended command parameters for Button Bar

Post by *petermad »

2thomasmolover
I just would not want to a commander windows flash beforce launch app
Then just use the iconic=1 parameter
Or in a button check the box "Run minimized"

It will only be the DOS box that is minimized, not your application.
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.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Dalai
Power Member
Power Member
Posts: 9388
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: add hash class extended command parameters for Button Bar

Post by *Dalai »

There are environment variables that are special to/in CMD: %RANDOM%, %CD%, %DATE%, %TIME%, %ERRORLEVEL% and some others (see SET /? in a CMD window). They're resolved by CMD at execution time. This means that TC won't be able to resolve any of them. Hence, the command must be executed via CMD in some way, like petermad showed in the second and third variant.

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
thomasmolover
Member
Member
Posts: 167
Joined: 2016-12-12, 01:32 UTC

Re: add hash class extended command parameters for Button Bar

Post by *thomasmolover »

Stefan2 wrote: 2020-04-21, 09:53 UTC 2thomasmolover
ghisler(Author) wrote: 2020-04-19, 08:14 UTC If you put environment variables in double % signs in the parameters field,
they will NOT be resolved by Total Commander.
They will be passed with single % signs to the target application.
It's then the duty of the target application to resolve them.
It's then the duty of the target application to resolve them.


Use an leading ? question sign in the Parameters box to see what TC will pass to AHK.


COMMAND: xxxxx\AHK\AutoHotkey.exe xxxx\ShowParameters.ahk
PARAMETERS: ?%%TEMP%% ### %%RANDOM%%
>>>?-DIALOG Shows: %TEMP% ### %RANDOM%
>>>OUTPUT: nothing (probably %...% are variables in AHK, and that non-existing vars in the script result in empty string)

Also passing %var% to an VBS script for example
For i = 0 to WScript.Arguments.Count -1
      MsgBox WScript.Arguments.Item(i)

will not automatically expand the vars, because VBS doesn't know what you want from it.
You can pass %var%s and then handle (expand) them inside the script by using VBS functions to do that.


With CMD it will work:
COMMAND: cmd /k
PARAMETERS: ?Echo %%TEMP%% # # # %%RANDOM%%
>>>?-DIALOG Shows: Echo %TEMP% # # # %RANDOM%
>>>OUTPUT: C:\Users\Stefan2Einer\AppData\Local\Temp # # # 20050


So your program can not handle environment variables (at least not that way).
Solution: Just call a ahk script from your button, use there the EnvVars you want (or utilize AHK functions) and call your application from there.
Thank you. I just think that the TC could support a direct parameter :).
If I use ahk or other script for the function, there are many ways to do what I want.

petermad wrote: 2020-04-21, 13:31 UTC 2thomasmolover
I just would not want to a commander windows flash beforce launch app
Then just use the iconic=1 parameter
Or in a button check the box "Run minimized"

It will only be the DOS box that is minimized, not your application.
Thank you. I just want a perfect method without any other app include CMD :)
Dalai wrote: 2020-04-21, 15:11 UTC There are environment variables that are special to/in CMD: %RANDOM%, %CD%, %DATE%, %TIME%, %ERRORLEVEL% and some others (see SET /? in a CMD window). They're resolved by CMD at execution time. This means that TC won't be able to resolve any of them. Hence, the command must be executed via CMD in some way, like petermad showed in the second and third variant.

Regards
Dalai
Thank you. that I can only use the script for it.
User avatar
Stefan2
Power Member
Power Member
Posts: 4155
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: add hash class extended command parameters for Button Bar

Post by *Stefan2 »

thomasmolover wrote: 2020-04-22, 10:50 UTC ...
Thank you. I just think that the TC could support a direct parameter :).
Ahh, I see, after all we are in the suggestions forum, ok, fine I got it now :D





 
Post Reply