Edit environmental variables used by Total Commander
Moderators: Hacker, petermad, Stefan2, white
- robinsiebler
- Senior Member
- Posts: 460
- Joined: 2003-03-05, 21:04 UTC
Edit environmental variables used by Total Commander
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.
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
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
Re: Edit environmental variables used by Total Commander
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.
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
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
https://www.ghisler.com
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:ghisler(Author) wrote:... when you change an environment variable in Explorer, only Explorer can see it ...
[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:
- HKEY_CURRENT_USER\Environment
- 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.
Re: Edit environmental variables used by Total Commander
Wouldn't you rather simply use a folder named "latest"?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
#5050 :: Everyone who believes in telekinesis, raise my hand!
- robinsiebler
- Senior Member
- Posts: 460
- Joined: 2003-03-05, 21:04 UTC
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
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
-
- Junior Member
- Posts: 39
- Joined: 2003-03-24, 10:47 UTC
Re: Edit environmental variables used by Total Commander
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: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%
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 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.