Page 1 of 1

add hash class extended command parameters for Button Bar

Posted: 2020-04-18, 19:13 UTC
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

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-18, 20:24 UTC
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.

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-19, 06:06 UTC
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

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-19, 08:14 UTC
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.

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-20, 12:48 UTC
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%%

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-21, 08:57 UTC
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

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-21, 09:07 UTC
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.

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-21, 09:53 UTC
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.



 

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-21, 13:31 UTC
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.

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-21, 15:11 UTC
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

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-22, 10:50 UTC
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.

Re: add hash class extended command parameters for Button Bar

Posted: 2020-04-22, 11:51 UTC
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