TC cannot correctly resolve some predefined variables
Moderators: white, Hacker, petermad, Stefan2
TC cannot correctly resolve some predefined variables
Predefined variable "%COMMANDER_PATH%" in "Parameters" cannot be resolved correctly.
Preconditions: Install TC to "C:\Program Files\totalcmd"
Steps to Reproduce:
1. Create new folder with path "C:\Test"
2. Run TC and navigate in active panel to folder "C:\Test"
3. Create under TC installation directory new folder with name "Extras"
4. Copy test script testPar.wsf inside this folder
5. In the TC's toolbar add new single button with the following:
Command: %COMMANDER_PATH%\Extras\testPar.wsf
Parameters: /param:"%COMMANDER_PATH%\Extras\test.xml"
6. After adding new button, click on it.
7. Check path passed in parameters.
Expected Result:
The path is: C:\Program Files\totalcmd\Extras\test.xml
Actual Result:
The path is: C:\Test\..OMMANDER_PATHExtras\test.xml
_______________________________________________________
Test environment: Windows 10, x64-based system
Tested on trial TCs with v9.12 (latest final as of the current date) and v9.20B6 (latest beta as of the current date).
Thus, predefined variable "%COMMANDER_PATH%" in "Command" will be resolved correctly, but in "Parameters" it is not.
It looks like "%C" in "%COMMANDER_PATH% is replaced by current path.
Preconditions: Install TC to "C:\Program Files\totalcmd"
Steps to Reproduce:
1. Create new folder with path "C:\Test"
2. Run TC and navigate in active panel to folder "C:\Test"
3. Create under TC installation directory new folder with name "Extras"
4. Copy test script testPar.wsf inside this folder
5. In the TC's toolbar add new single button with the following:
Command: %COMMANDER_PATH%\Extras\testPar.wsf
Parameters: /param:"%COMMANDER_PATH%\Extras\test.xml"
6. After adding new button, click on it.
7. Check path passed in parameters.
Expected Result:
The path is: C:\Program Files\totalcmd\Extras\test.xml
Actual Result:
The path is: C:\Test\..OMMANDER_PATHExtras\test.xml
_______________________________________________________
Test environment: Windows 10, x64-based system
Tested on trial TCs with v9.12 (latest final as of the current date) and v9.20B6 (latest beta as of the current date).
Thus, predefined variable "%COMMANDER_PATH%" in "Command" will be resolved correctly, but in "Parameters" it is not.
It looks like "%C" in "%COMMANDER_PATH% is replaced by current path.
Hi and welcome.
Please follow the rules of MS-DOS and double the per-cent signs if used in Parameter box.
Command: cmd /k
Parameters: ECHO %Commander_Path% & ECHO %%Commander_Path%%
For you, TC have seen "%C", which is an parameter on its own. (Next then TC gets "ommander_Path" and "%\" as parameters)
(open an button for modifying, then press F1 and read more at the help)
Also, for your case, best use quotes in Command box too.
Please follow the rules of MS-DOS and double the per-cent signs if used in Parameter box.
Command: cmd /k
Parameters: ECHO %Commander_Path% & ECHO %%Commander_Path%%
For you, TC have seen "%C", which is an parameter on its own. (Next then TC gets "ommander_Path" and "%\" as parameters)
(open an button for modifying, then press F1 and read more at the help)
Also, for your case, best use quotes in Command box too.
Double the per-cent signs works for your simple case with command window, but still doesn't work in described bug.Stefan2 wrote:Hi and welcome.
Please follow the rules of MS-DOS and double the per-cent signs if used in Parameter box.
Command: cmd /k
Parameters: ECHO %Commander_Path% & ECHO %%Commander_Path%%
For you, TC have seen "%C", which is an parameter on its own. (Next then TC gets "ommander_Path%" as parameter)
(open an button for modifying, then press F1 and read more at the help)
Also, for your case, best use quotes in Command box too.
After double the per-cent signs I have the following result:
The path is: %COMMANDER_PATH%\Extras\test.xml
Well, as far as I remember, it's up to the called app to resolve (expand) the env var.Sysman wrote:Double the per-cent signs works for your simple case with command window, but still doesn't work in described bug.Stefan2 wrote:.
After double the per-cent signs I have the following result:
The path is: %COMMANDER_PATH%\Extras\test.xml
Other takers please.... Am I right?
Ahh, moment, check it with a leading '?' question-mark sign in the Parameter box
Command: cmd /k
Parameters: ? ECHO %Commander_Path% & ECHO %%Commander_Path%%
You see, TC doesn't expand that var. The called app has to do this. The commandlineinterpreter is able to do this.
- - -
Proof of example
Button:
Command: z.VBS
Parameter: %COMMANDER_PATH% # %%COMMANDER_PATH%%
z.VBS:
msgbox wscript.arguments(0) & vbLF & wscript.arguments(1)
Result:
---------------------------
---------------------------
X:\temp\z.vbsOMMANDER_PATH#
%COMMANDER_PATH%
---------------------------
OK
---------------------------
Solution:
Use smtg like
SET WSO = WScript.CreateObject("WScript.Shell")
TCPath = WSO.ExpandEnvironmentStrings("%Commander_Path%")
myPath=TCPath & "\Extras\test.xml"
in your script.
Sysman wrote:I can agree with you, but why does then TC expand "%C" in "%COMMANDER_PATH%" in passed parameter to current path?
TC see first "%C", which is an parameter on its own.
See the help:
%C1 : First selected file, or file under cursor
Test it yourself:
Cmd: cmd /k
Para: ECHO %C & ECHO %C1
No, it's by design.Therefore I consider it as a bug.
But you are the only one, its not a bug.Sysman wrote:I can agree with you, but why does then TC expand "%C" in "%COMMANDER_PATH%" in passed parameter to current path?
Therefore I consider it as a bug.
Its by design.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
TC 11.03 x64 / x86
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
TC 11.03 x64 / x86
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
You want to say me that one predefined variable (%C) is expanding in parameters, but other predefined variable (%COMMANDER_PATH%) is not, and it's not a bug, and it's all by design.
I'm confused. Could you please give me a link where I will be able to see which predefined variables are expanding in parameters?
I'm confused. Could you please give me a link where I will be able to see which predefined variables are expanding in parameters?
> viewtopic.php?p=342566#342566Sysman wrote:...Could you please give me a link where I will be able to see which predefined variables are expanding in parameters?
> sentence no. 6
Well, it is really not a bug but by design.
TC does expand envvars in Command field but doesn't in Parameters field, because the latter one uses %parameter syntax (a single % character and some letters/digits) which conflicts with %envvar% syntax. So you can either move part of command line with envvar to Command field or double % characters to pass them to a program unchanged, but in such case the program should be able to expand them:
As it was said, you can read about %parameters in help:
TC does expand envvars in Command field but doesn't in Parameters field, because the latter one uses %parameter syntax (a single % character and some letters/digits) which conflicts with %envvar% syntax. So you can either move part of command line with envvar to Command field or double % characters to pass them to a program unchanged, but in such case the program should be able to expand them:
Code: Select all
Command: "%COMMANDER_PATH%\Extras\testPar.wsf" /param:"%COMMANDER_PATH%\Extras\test.xml"
Parameters:
Code: Select all
Command: "%COMMANDER_PATH%\Extras\testPar.wsf"
Parameters: /param:"%%COMMANDER_PATH%%\Extras\test.xml"
Stefan2 wrote:(open an button for modifying, then press F1 and read more at the help)