Edit environmental variables used by Total Commander

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Edit environmental variables used by Total Commander

Post by *robinsiebler »

I have some directories that I commonly use, but every time a new build comes out (I test software), the main directory changes. For instance:

On Monday I might access c:\Builds\02_600PA\PDK.
On Tuesday, it becomes c:\Builds\03_600PA\PDK.

I had the idea of setting an environmental variable and having the Directory menu use that. For instance:

set CurrBld=c:\Builds\03_600PA\PDK

In TC:
Command: cd %CurrBld%

However, the problem with this is I have to perform the following steps each time a new build comes out:

a) Close all instances of TC
b) Open the System Properties and update the environmental variable
c) Relaunch TC.

I am wondering if there is a better way of doing this. If not, it would be nice to be able to either a) edit the variables in TC's environment space or b) if TC was modified to have it's own user modifiable variables.
Robin L. Siebler
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Re: Edit environmental variables used by Total Commander

Post by *jb »

I would also appreciate if TC would detect changes to environment variables on system and user level as the Windows Explorer does. So it would no longer be necessary to quit and restart TC after such changes.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The problem is that when you change an environment variable in Explorer, only Explorer can see it, and not any programs started by Explorer - only those started AFTER the change...
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 »

ghisler(Author) wrote:... when you change an environment variable in Explorer, only Explorer can see it ...
I was not aware that changing system or user environment variables by Start\Settings\Control Panel\System involves the Explorer. But I've just found out that in this case the "System Properties" dialog is really started by the Explorer. It uses the following command line:
[face=courier]"%SystemRoot%\system32\rundll32.exe" shell32.dll,Control_RunDLL "%SystemRoot%\system32\SYSDM.CPL",System[/face]

Then I have guessed that accessing the Control Panel\System from TC via cm_OpenControls would be a nice solution. Unfortunately it does not work, although it seems that TC calls the "System Properties" dialog with exactly the same command line as the Explorer.

But even if it worked it would not be a complete solution, because system or user environment variables may also be changed by regedit.exe or by any application using the RegSetValueEx() function of the Windows SDK.
Example: Occasionally I use a script that generates a .reg file and then calls regedit.exe to change environment variables (among other things).

I think a proper solution would be to apply the RegNotifyChangeKeyValue() function of the Windows SDK to the following two registry keys:
  1. HKEY_CURRENT_USER\Environment
  2. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Last edited by jb on 2003-04-04, 19:32 UTC, edited 1 time in total.
User avatar
CopyCats
Member
Member
Posts: 195
Joined: 2003-02-05, 13:09 UTC
Location: Netherlands
Contact:

Re: Edit environmental variables used by Total Commander

Post by *CopyCats »

robinsiebler wrote:I have some directories that I commonly use, but every time a new build comes out (I test software), the main directory changes
Wouldn't you rather simply use a folder named "latest"?
#5050 :: Everyone who believes in telekinesis, raise my hand!
User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Post by *robinsiebler »

How about being to have variables that are only used internally by TC? Currently I am setting a system wide environmental variable that I am *only* using in TC. If I could set a variable inside TC, that only TC could see, then I wouldn't have to set a system wide variable and I wouldn't have to restart TC when I changed the variable. I suppose that I could just change the Directory menu every time, but if TC had variables, I am sure I (and many others as well) could find lots of uses for them.
Robin L. Siebler
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
HenrikHusted
Junior Member
Junior Member
Posts: 39
Joined: 2003-03-24, 10:47 UTC

Post by *HenrikHusted »

I think that TC should respond to the WM_SETTINGCHANGE message and reload the environment variables, then it should work.

.H
User avatar
Valentino
Power Member
Power Member
Posts: 706
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

2HenrikHusted
As far as I remember the problem was how to get these variables via API. Someone suggested to read them from registry.
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

Valentino wrote:As far as I remember the problem was how to get these variables via API. Someone suggested to read them from registry.
If you want to refresh your memory just go 5 posts up.
User avatar
Valentino
Power Member
Power Member
Posts: 706
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

2jb
Yes, my prev post wasn't clear enough. Saying "the problem was" I meant Christian had this problem (how to get env variables via Windows API). This subj was discussed on old forum and someone suggested to take new env vars from registry.
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Re: Edit environmental variables used by Total Commander

Post by *wanderer »

robinsiebler wrote:I have some directories that I commonly use, but every time a new build comes out (I test software), the main directory changes. For instance:

On Monday I might access c:\Builds\02_600PA\PDK.
On Tuesday, it becomes c:\Builds\03_600PA\PDK.

I had the idea of setting an environmental variable and having the Directory menu use that. For instance:

set CurrBld=c:\Builds\03_600PA\PDK

In TC:
Command: cd %CurrBld%
You do not specify the O/S you are using but if it's based in NT (W2K, WinXP), then the following util may solve your problem:

http://www.sysinternals.com/ntw2k/source/misc.shtml#junction

Just use it like this (from command line):

C:
cd C:\Builds
junction LatestBuild 03_600PA

Then all you have to do is cd C:\Builds\LatestBuild :)

If the build changes, just exit all programs running or using "C:\Builds\LatestBuild", do a "junction LatestBuild 03_600PB" as described above and continue working. Note that if you are somewhere inside the LatestBuild dir from a TC window (without having any open files though), when you use junction, TC just refreshes the view to contain the new files, it does not produce any errors.

You could also make a button in the button bar:
command : C:\junction.exe
parameters : LatestBuild %N

Use it with causion though, you may get lost if you create too many junctions. Windows (W2k at least) do not show the junction folder with any special icon like in shared folders.

A final note: when you delete a junction from within TC, O/S just deletes the junction, not the dir it's connected to.

Have fun
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
Post Reply