Jump to content

Environment variables?


dbminter
 Share

Recommended Posts

Anyone know of a SIMPLE way to add and change Environment variables in XP? Thus far, the only ways I have found are far more complicated than they need to be. But, this IS Microsoft we are talking about here, so, it's probably IMPOSSIBLE to do it any other way. Seems to me the only ways are to either do it in through System in Control Panel, which means opening a menu and several sub menus, change/add them, and sometimes REBOOT the entire damn system! (Who knows? Logging off may work, too.) The Command Prompt is relatively useless because once it's closed, any SETs made are conveniently forgotten. So, the only way to do that is to always have a Command Prompt open, eating away at resources.

Link to comment
Share on other sites

Yes, I know. :D STILL, that requires a lot of needless multiple menu opening. And, even then, you sometimes have to restart Windows in order for some applications to recognize the variables have changed. (Some just require closing and reopening, like the dumb as a post WinBatch.)

Link to comment
Share on other sites

Christ! Now, I have to figure out what the latest piece of Microsoft garbage is! I can set the following User variables to my temporary directory, TEMPDIR and TEMP, by first setting TEMPDIR and then setting TEMP equal to %TEMPDIR% BUT, if I set TMP equal to %TEMPDIR%, programs go haywire! Saying they can't write to a file. Probably because they can't write to however messed up Microsoft has made TMP. Must be some kind of internal reserved variable different than TEMP, which is also present in the System variables, but, I can alter that one just fine! :angry:

Link to comment
Share on other sites

Yep, it's official. Microsoft somehow managed to screw up the simple Environment variable TMP! :rolleyes: The reason TMP goes haywire when you try to use substitution (%%) is, apparently, Windows decides to set TMP NOT the value of the variable within the %'s, but, to a ~1 version of 8.3 EVEN IF THE VARIABLE IS ONLY 8 CHARACTERS OR LESS! IDIOTS! :angry: So, what happens is when I set TMP=%TEMPDIR%, it actually sets TMP to the value "%TEMPDI~1" That's why it blows up. The programs try to insert what SHOULD be a directory from TMP and, instead, inserts as the directory name %TEMPDI~1, which is an impossible value to process for a directory name because of the % sign! The problem appears to be that the Registry entry for TMP MUST use \\ instead of \ AND, unlike the OTHER variables, does NOT automatically translate \'s into \\'s when inserting them into the Registry keys.

Link to comment
Share on other sites

Anyone happen to know "where" the SET variables that are Parsed from AUTOEXEC.BAT, if you have enabled that Logon option in TweakUI, are "stored?" By this, I know they're not stored as DOS environment variables. You can go into a Command Prompt and change a SET value that was Parsed, BUT, once you close the Command Prompt, those values revert back to the values Parsed in. And, even IF you leave the Command Prompt open, as I discovered :) even WHEN SET TELLS you the value is different, the ACTUAL value that was Parsed in was NOT changed. This means that there must be parallel copies being stored. They have the name variable names but are not the same variables. Because, there's only two answers to the problem I face:

 

1.) store these variables as User or System environment variables in the System tab. The problem here is %% substitutions are a 50/50 proposition. Some variables, like TMP, don't add them correctly.

 

2.) store these variables in SET commands in AUTOEXEC.BAT and Parse them on Logon. This way, I can use %% substitution, but, the draw back is these values do NOT show up as either User or System environment variables. Thus, they cannot be actively changed. The only way to change them is to edit AUTOEXEC.BAT, log off, and log back in so AUTOEXEC.BAT gets parsed again.

Link to comment
Share on other sites

Or... what I could do is this! I feel like such a :albert: IF this works! :D

 

1.) SET the variables in AUTOEXEC.BAT so I can use %% substitution when desired.

2.) Parse the AUTOEXEC.BAT on Logon

3.) For each (Well, I am guessing some like TMP simply won't cooperate.) SET variable in AUTOEXEC.BAT, add an entry in the User variables pointing to itself with a substitution, e.g. "TEMPDIR"="%TEMPDIR%" so they get added to the Registry at [HKEY_CURRENT_USER\Environment]

4.) Query the key for its value, e.g. in the above, REGCurrent at Environment\[TEMPDIR]

 

Now, in theory :wink: this should get the value to insert into %TEMPDIR% from AUTOEXEC.BAT, insert that value into %TEMPDIR% in the User variable, set TEMPDIR equal to the value inserted at %TEMPDIR%, and store that full value, with no %'s in the variables, at [HKEY_CURRENT_USER\Environment\TEMPDIR] That way, I can change the value in System without a logon for testing purposes, STILL be able to read that value, this time from the Registry, and have the ability to use %% substitution.

Link to comment
Share on other sites

I don't know WHAT I was thinking of there! :lol: Of COURSE the above works... BUT, it just adds unnecessary steps to do the same thing! :doh: It's like saying you wanted to leave yourself a note and, instead of just writing it down on apiece of paper and sticking it on the fridge door, you get in your car, drive 50 miles away, and use your cel phone to leave yourself the same message on your answering machine.

 

 

Since the information I need is ALREADY stored in the Registry Keys, just POLL the keys! Remove the unnecessary steps of adding them in for Parsing...

Link to comment
Share on other sites

I'm going to pretend That I know what DB is talking about. :w00t:

 

Parse the AUTOEXEC.BAT on Logon

 

What Ver of windows are you running?

 

And, I must repeat shamus' question, WTF are you trying to do? :D

Link to comment
Share on other sites

Or... what I could do is this! I feel like such a :albert: IF this works! :D

 

1.) SET the variables in AUTOEXEC.BAT so I can use %% substitution when desired.

2.) Parse the AUTOEXEC.BAT on Logon

3.) For each (Well, I am guessing some like TMP simply won't cooperate.) SET variable in AUTOEXEC.BAT, add an entry in the User variables pointing to itself with a substitution, e.g. "TEMPDIR"="%TEMPDIR%" so they get added to the Registry at [HKEY_CURRENT_USER\Environment]

4.) Query the key for its value, e.g. in the above, REGCurrent at Environment\[TEMPDIR]

 

Now, in theory :wink: this should get the value to insert into %TEMPDIR% from AUTOEXEC.BAT, insert that value into %TEMPDIR% in the User variable, set TEMPDIR equal to the value inserted at %TEMPDIR%, and store that full value, with no %'s in the variables, at [HKEY_CURRENT_USER\Environment\TEMPDIR] That way, I can change the value in System without a logon for testing purposes, STILL be able to read that value, this time from the Registry, and have the ability to use %% substitution.

 

 

If I sound like a non-progamming computer peasant, so be it. julli-baby.gif I admit, this is so much Programmese to me.

 

On the other hand, when I did tech support for Dell, there were people who couldn't find their C: partition. Ignorance, like most everything else, is relative.

 

Frankly, if I boot up or type in my password and the desktop comes up, I say a silent prayer to the PC Gods and go with it. julli-tumcool.gif

 

The more I learn about programming, the more I'm glad I chose to pursue graduate work in sex, drugs and rock n' roll. julli-pot.gif

 

But exactly what are you trying to accomplish here, minty?

Link to comment
Share on other sites

Since the information I need is ALREADY stored in the Registry Keys, just POLL the keys! Remove the unnecessary steps of adding them in for Parsing...

Might I ask, Oh, Great Fettler of the Registry Keys, what exactly are you trying to do? :blink:

 

 

Ah, I feel much better. julli-thumbup2.gif Seamus be unclear as to minty's aim as well.

Link to comment
Share on other sites

Well, ever notice how when you make one change to the location of something, like the Start Menu or the Desktop, you screw up, at least, 10 other variables in programs/system variables/user variables/Registry keys that EACH need to be altered to make the one minor change? Well, I was trying to minimize the damage. When I make these changes, I had intended to make a change to a SET variable to reflect this change. Then, the system would have these changes in a variable at start and programs I write could poll these variables and insert the directory locations in at execute time. That way, I don't have to change a dozen variables' worth of data, and just change 1.

 

 

So, what I am thinking of doing is allocating the type of variables TweakUI can set to just polling the Registry for their keys' values in my code. Then, set a few of my own personals, like the directory where the code that is executed (I pass the code to the compiler to run rather than making .EXE's because each time such a program is changed for whatever reason, it would require a recompile.) is stored. That way, any code that makes internal calls to other code to execute won't need my editing the code to reflect a change in the directory where both pieces of code are stored.

 

 

I wanted to be able to use %% substitution wherever possible because some variables use similar common strings. Thus, to change 2, I would only need to edit one string. For instance, Start Menu and Programs in TweakUI each share the same common string of the location of Start Menu. BUT, since the system DOES all you to store the Start Menu in one location AND the Programs Menu somewhere else... IDIOTS!... the user is allowed to make such a change. Thus, BOTH variables HAVE to be set! :rolleyes: My way, a change to where the Start Menu is only requires my editing one variable to reflect the change in both because the %% substitution would place the Start Menu variable contents in to the Programs variable contents as needed.

 

 

The problem in the User and System variables that can be set in the System shortcut is they only seem to accept %% substitutions if they can pull the contents from SET variables and not from themselves. For whatever stupid reason. The way around this IS to SET the variables in AUTOEXEC.BAT and Parse them, and then set the same variables in the User/System variables to substitute themselves. e.g. DIRCMD=%DIRCMD% HOWEVER, not ALL variables accept this convention! TMP is one of them, it seems. WHY, blame a lazy, stupid, or both :D Microsoft programmer, I say. There's NO reason why TMP SHOULD be any different from another variable, but, what is is.

Link to comment
Share on other sites

Well, he *is* running Windows so he?s off to a good start. =))

You think I'd use this piece :horse: if I had any other viable choice? :D It's how Big Bill manages to light his bong with hundred dollar bills, so, you think he's going to allow any real choice? Notice how his name is Bill? It used to be Rutherford, but, after he got rich, he went berserk and decided to change his name so everyone will know who is sitting on top of the world's real Uncle Scrooge Money Bin. :unsure:

Link to comment
Share on other sites

after he got rich, he went berserk and decided to change his name so everyone will know who is sitting on top of the world's real Uncle Scrooge Money Bin.

If nothing else, I've got to love the way you think DB. :whistling:

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.