Switching Environment Variables in XP
Discussion
Morning all,
Here's a little one to tax those brain cells on a Friday.
I have a developer who wishes to run 2 different C compilers on the same PC. Unfortunatly both compilers use the same environment variables names, but need to point to differing paths etc.
One possible solution is to enable him to log in with a different username. However due to 'corporate' restrictions this is not possible. I've done a search using Google, but couldn't come up with anything.
Anybone any ideas?
Thanks
Here's a little one to tax those brain cells on a Friday.
I have a developer who wishes to run 2 different C compilers on the same PC. Unfortunatly both compilers use the same environment variables names, but need to point to differing paths etc.
One possible solution is to enable him to log in with a different username. However due to 'corporate' restrictions this is not possible. I've done a search using Google, but couldn't come up with anything.
Anybone any ideas?
Thanks
What I think you can do is create a batch file that first sets the environment variables as required and then goes on to start the program that corresponds to the compiler (e.g. Visual Studio).
Then, create a desktop shortcut to the batch file for ease of use.
{eta:} I think you'll need to do it this way as otherwise the context that the compiler is running in won't have visibility of the (temporary) environment variables that the batch file sets up.
>> Edited by pdV6 on Friday 13th January 10:16
Then, create a desktop shortcut to the batch file for ease of use.
{eta:} I think you'll need to do it this way as otherwise the context that the compiler is running in won't have visibility of the (temporary) environment variables that the batch file sets up.
>> Edited by pdV6 on Friday 13th January 10:16
Also worth bearing in mind:
If you have a command window open, and change the environment variables through windows, the command window will not recognize the changes and continue using the old ones.
So, (if you're using a cmd window) you could load a command window with one set of environment variables, change them, load another new one, and voila you have two sets of encironment variables.
I'm 90% sure this will work anyway...
Russell
If you have a command window open, and change the environment variables through windows, the command window will not recognize the changes and continue using the old ones.
So, (if you're using a cmd window) you could load a command window with one set of environment variables, change them, load another new one, and voila you have two sets of encironment variables.
I'm 90% sure this will work anyway...
Russell
pdV6 said:
{eta:} I think you'll need to do it this way as otherwise the context that the compiler is running in won't have visibility of the (temporary) environment variables that the batch file sets up.
>> Edited by pdV6 on Friday 13th January 10:16
So would that be why when I used SET from the command line, and then looked in My computer/Properties/Advanced/environment Variables it did not show a test variable that I set up? However, when I did a set (on it's own) the variable was there. It must be a context thing?
If he's a developer worth having, then he'll just spend the three minutes it takes to write a short program that can run as a tool in the development environment, that adjusts the environment variable;
WIN32API Reference said:
The SetEnvironmentVariable function sets the value of an environment variable for the current process.
BOOL SetEnvironmentVariable(
LPCTSTR lpName, // address of environment variable name
LPCTSTR lpValue // address of new value for variable
);
Parameters;
lpName
Pointer to a null-terminated string that specifies the environment variable whose value is being set. The operating system creates the environment variable if it does not exist and lpValue is not NULL.
lpValue
Pointer to a null-terminated string containing the new value of the specified environment variable. If this parameter is NULL, the variable is deleted from the current process's environment.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
annodomini2 said:
Surely you could do this from the make file? Assuming you're using make?
>> Edited by annodomini2 on Friday 13th January 15:37
Probably can.
Most people these days don't have a clue if you ask them to deal with the linker directly. Most people (me included) have forgotten that you used to have to compile assemble link and make!
Edited to add;
You only get a job these days, if you know ASP and VB!
>> Edited by dilbert on Friday 13th January 15:43
sprintmp said:
I have a developer who wishes to run 2 different C compilers on the same PC. Unfortunatly both compilers use the same environment variables names, but need to point to differing paths etc.
I don't see any reason to consider multiple logins, virtual PCs etc. This is massive overkill for what should be a trivial problem.
How does your developer invoke the compiler - command line, GUI etc?
Thanks guys for all the input.
The guy is good, but mainly uses Linux. I must admit, if I'd have thought about it a little more , I'd have gone for the batch file option. Unfortunatly we had another crisis on at the time....
So who remembers LDX, Move, SRC, SLC etc? Or even #XQMY (for 'scratching' tapes). There is a bit of history here http://en.wikipedia.org/wiki/ICT_1900 including a link for a George 3 emulator to run on PCs, Solaris & Linux. Also here www.fcs.eu.com/index.html (which has loads of stuff) - ah! those were the days!
The guy is good, but mainly uses Linux. I must admit, if I'd have thought about it a little more , I'd have gone for the batch file option. Unfortunatly we had another crisis on at the time....
So who remembers LDX, Move, SRC, SLC etc? Or even #XQMY (for 'scratching' tapes). There is a bit of history here http://en.wikipedia.org/wiki/ICT_1900 including a link for a George 3 emulator to run on PCs, Solaris & Linux. Also here www.fcs.eu.com/index.html (which has loads of stuff) - ah! those were the days!
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


