ability to set environment variables

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
tocmd
Junior Member
Junior Member
Posts: 3
Joined: 2007-11-13, 14:09 UTC

ability to set environment variables

Post by *tocmd »

Why can't I use the SET or call command?
Is there another way to define a set of environment variables during runtime of totalcommander?

What I do right now is create a bat with the following:

SET JAVA_HOME=xxxxx
SET SRC_PATH=xxxxx
SET PROJECT_PATH=xxxxx
SET PROJECTBAT=genant.bat
start c:\totalcmd\totalcmd.exe

and I have three of these bats so that for each project that I work on I can use the same shortcuts.

It would be good for me to swich by pressing a button, and changing the above Environment variables.
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

1. SET and CALL are console commands, not standalone tools, so of course you have to start the console first:

Code: Select all

%comspec% /c set bla=blubb && set blabla=blubbblubb [...]
2. You cannot make the parent TC instance inherit changes done with SET in child console windows, you have to set envvars first and then start TC, like you do now, if you want the changes to be temporary only.
3. If you want to update the current TC instance with envvars, you can use SETX, available in directory \Support\Tools on the XP CD. The envvar changes are PERMANENT and TC updates accordingly since TC 7.

Icfu
This account is for sale
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

icfu wrote:2. You cannot make the parent TC instance inherit changes done with SET in child console windows, you have to set envvars first and then start TC, like you do now, if you want the changes to be temporary only.
Nope, it is possible. I don't know about any tool that does it, but it may exist, it's not too hard to write.
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Of course it exists, it's mentioned under 3).
Under 2) I was talking about SET!

Icfu
This account is for sale
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

icfu wrote:Of course it exists, it's mentioned under 3).
Under 2) I was talking about SET!

Icfu
AFAIR SETX sets variables in the registry, right?
It doesn't affect only TC and it's child processes, which can be a problem sometimes. You can force TC to set own env vars and this works exactly like SET.
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

m^2 wrote:You can force TC to set own env vars and this works exactly like SET.
How can we do this, please???

Karl
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

karlchen wrote:
m^2 wrote:You can force TC to set own env vars and this works exactly like SET.
How can we do this, please???

Karl
Code injection and call to SetEnvironmentVariable.
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Ok, I see. - So I have not missed a new T.C. feature. - And this idea will not really be available to the non-programmers.

Karl
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

AFAIR SETX sets variables in the registry, right?
Yep, this is the storage location for the Windows long-term memory.
It doesn't affect only TC and it's child processes, which can be a problem sometimes.
Indeed, but I am not the one to decide what problems users create on their boxes. tocmd isn't happy with setting envvars before starting TC, so this is an alternative.
Code injection and call to SetEnvironmentVariable.
Yeah, hack the planet! You know that I like dirty tricks, but I am also always asking myself if it's our job to do what would be ghisler's job. ;)
Most of the time my answer is YES of course, just because my life isn't endless and ghisler's enhancements to TC often need several years to be proposed, rejected, discussed and finally be realized – or not. Changing envvars in current TC instance is on position 2768 on his wishlist, I guess...

Icfu
This account is for sale
Rob Weinstein
Junior Member
Junior Member
Posts: 45
Joined: 2006-06-10, 21:41 UTC
Location: Arizona

Post by *Rob Weinstein »

SETENV is another utility like SETX that creates or changes environment variables immediately in TC:

http://barnyard.syr.edu/%7Evefatica/#SETENV

I like SETENV better than SETX because it has an option to delete environment variables without directly editing the registry. Unfortunately, when deleting an environment variable with SETENV, TC doesn't get updated immediately, you have to close it and open it again.

-Rob
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Very useful app, thanks!

With it one can create envvars which are automatically deleted on logoff and reboot:

Code: Select all

setenv -v var value
Icfu
This account is for sale
User avatar
Sombra
Power Member
Power Member
Posts: 814
Joined: 2005-12-27, 22:23 UTC
Location: Zaragoza, Spain

Post by *Sombra »

Sorry for interfere in the conversation, but... The plugin Environment Variables (WFX)... Can not do that? or maybe, Am I missing anything?
One example: If I change the variable COMMANDER_PATH, TC take the new value immediately.
I can read English, but... I write like Tarzan. (sorry)
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

It can do that, but only one by one. There is no chance for automation, like requested by the OP.

Icfu
This account is for sale
User avatar
Sombra
Power Member
Power Member
Posts: 814
Joined: 2005-12-27, 22:23 UTC
Location: Zaragoza, Spain

Post by *Sombra »

Aha, I see Now.
I can read English, but... I write like Tarzan. (sorry)
Post Reply