New internal commando cm_OpenMyDocuments

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

jb wrote:But in this case TC is supposed to expand %$PERSONAL% because only TC knows the definition.
:oops: You are right.
Notepad++ baffles me because i'd opened the %$PERSONAL%\file.txt before from the expanded path.
But ProcessExplorer revealed that the %$PERSONAL% parameter is not expanded in the command line.
So it's indeed a bug?

Regards
Holger
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

HolgerK wrote:... ProcessExplorer revealed that the %$PERSONAL% parameter is not expanded in the command line.
So it's indeed a bug?
The following example of a toolbar button shows that it is certainly a bug.

Code: Select all

Command:    notepad++.exe "%$PERSONAL%\NppPortable\readme.txt"
Parameters: %$PERSONAL%\NppPortable\license.txt
Start path: %$PERSONAL%\NppPortable
Icon file:  %$PERSONAL%\NppPortable\notepad++.exe
Total Commander shows the icons of notepad++.exe and invokes notepad++.exe with the following command line:

Code: Select all

"C:\Dokumente und Einstellungen\jb\Eigene Dateien\NppPortable\notepad++.exe" "C:\Dokumente und Einstellungen\jb\Eigene Dateien\NppPortable\readme.txt" PERSONALNppPortable\license.txt
CONCLUSION: Total Commander expands pseudo environment variables (such as %$PERSONAL%) everywhere except in the "Parameters:" part.
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo »

Shouldn't it be %%$PERSONAL%% when used in the parameter line in TC? I'm using it there and it works fine.
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48097
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

No, it's not a bug. Environment variables are expanded ONLY in the "Command" field, not in the "Parameters" field. Why? They could collide with internal parameters like %P, %N etc.

Try this instead:
Command: notepad++.exe "%$PERSONAL%\NppPortable\readme.txt" %$PERSONAL%\NppPortable\license.txt
Parameters: (leave field empty)
Author of Total Commander
https://www.ghisler.com
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

Boofo wrote:Shouldn't it be %%$PERSONAL%% when used in the parameter line in TC?
No. See a few posts above http://ghisler.ch/board/viewtopic.php?p=174109&highlight=#174109

EDIT: Fixed the hyperlink.
Boofo wrote:I'm using it there and it works fine.
Really?
Last edited by jb on 2009-06-09, 16:29 UTC, edited 1 time in total.
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

ghisler(Author) wrote:No, it's not a bug. Environment variables are expanded ONLY in the "Command" field, not in the "Parameters" field. Why? They could collide with internal parameters like %P, %N etc.
What does that mean exactly? Please give me an example of such a collision.

EDIT:
Up to here this thread was mainly about pseudo environment variables. Therefore I overlooked that you made a more general statement about any type of environment variables. In the meantime I tried to summarize the whole picture in http://www.ghisler.ch/board/viewtopic.php?p=174418#174418.
Last edited by jb on 2009-06-10, 05:06 UTC, edited 3 times in total.
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo »

jb wrote:
Boofo wrote:Shouldn't it be %%$PERSONAL%% when used in the parameter line in TC?
No. See a few posts above http://www.ghisler.ch/board/posting.php?mode=quote&p=174109
Boofo wrote:I'm using it there and it works fine.
Really?
Yes, really. ;)

Code: Select all

Command: TOTALCMD.EXE
Parameters: /o /l=%%$PERSONAL%%
Start Path: %COMMANDER_PATH%\
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

Boofo wrote:Yes, really. ;)

Code: Select all

Command: TOTALCMD.EXE
Parameters: /o /l=%%$PERSONAL%%
Start Path: %COMMANDER_PATH%\
Nice try. :)
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo »

What do you mean "nice try"? It works. I am using it. There was a big conversation about this a few days back.

http://ghisler.ch/board/viewtopic.php?p=172820#172820
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

Boofo wrote:What do you mean "nice try"? It works. I am using it. There was a big conversation about this a few days back.

http://ghisler.ch/board/viewtopic.php?p=172820#172820
It works only because the target program is Total Commander itself. No other program knows how to expand %$PERSONAL% (as already explained in the post that I have referenced in my first reply). It's a kind of recursion. So I thought you made a joke.
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo »

Ok, I see what you meant. I haven't tried opening anything in My Documents as I don't store anything there. And since TC is all I use, that is why I do it that way. Any documents I would want to open would probably have an association already with it. I will have to play with it now to see what I can come up with. ;)
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

ghisler(Author) wrote:Environment variables are expanded ONLY in the "Command" field, not in the "Parameters" field. Why? They could collide with internal parameters like %P, %N etc.
That's not quite correct.

There are internal parameters (such as %P, %N etc.) and the following types of environment variables:
1. Normal environment variables (predefined by Windows such as %ProgramFiles% or user-defined)
2. Pseudo environment variables of Total Commander (such as %$PERSONAL%)

Total Commander expands internal parameters only in the "Parameters" field of buttons and start menu items.

Total Commander expands environment variables in the following places:
1. "Command" field of buttons and start menu items
2. "Start path" field of buttons and start menu items
3. "Icon file" field of buttons
4. cm_editpath field
5. command line
...?
but NOT in the "Parameters" field because for example %P%N could collide with a normal (user-defined) environment variable %P%.
Pseudo and normal env vars are treated equally although (as far as I understand) internal parameters could not collide with pseudo env vars.

I think environment variables really deserve a chapter in the online help of Total Commander and hyperlinks in the related chapters, first of all in "Dialog box: Configuration - Change button bar" and "Dialog box: Change start menu".
Post Reply