Page 1 of 1

ability to set environment variables

Posted: 2008-01-09, 16:12 UTC
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.

Posted: 2008-01-09, 16:46 UTC
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

Posted: 2008-01-09, 17:24 UTC
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.

Posted: 2008-01-09, 17:29 UTC
by icfu
Of course it exists, it's mentioned under 3).
Under 2) I was talking about SET!

Icfu

Posted: 2008-01-09, 18:48 UTC
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.

Posted: 2008-01-09, 22:20 UTC
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

Posted: 2008-01-09, 23:23 UTC
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.

Posted: 2008-01-10, 00:12 UTC
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

Posted: 2008-01-10, 00:45 UTC
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

Posted: 2008-01-10, 03:28 UTC
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

Posted: 2008-01-10, 07:40 UTC
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

Posted: 2008-01-10, 11:40 UTC
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.

Posted: 2008-01-10, 12:29 UTC
by icfu
It can do that, but only one by one. There is no chance for automation, like requested by the OP.

Icfu

Posted: 2008-01-10, 12:41 UTC
by Sombra
Aha, I see Now.