Solved

Setting system level environment variables through a batch file or software package

Posted on 2007-12-06
4
3,320 Views
Last Modified: 2012-08-14
We need to set system level environment variables and many XP systems. Also, we need to change them frequently. Is there an easier way to do it than typing them in manually? Is there a software package that can do it?
0
Comment
Question by:rdefino
4 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 250 total points
ID: 20421083
0
 
LVL 2

Assisted Solution

by:biggy_b
biggy_b earned 250 total points
ID: 20421168
You could try via cmd script.

"Using the add-on tool Setx.exe

It is not part of the standard Windows XP setup but a command-line tool called setx.exe is included in the Windows XP Service Pack 2 Support Tools. This tool extends the set command so that permanent changes in the environment variables can be made. For example, to add a folder C:\New Folder to the path, the command would be
setx path "%PATH%;C:\New Folder" "
http://vlaurie.com/computers2/Articles/environment.htm

This command-line tool offers a batch method for setting environmental variables in the user or system environment and requires no programming or scripting. In addition to taking an environmental variable and its associated value from the command line, it can also get the values of registrykeys and write them to text files.

Here is a python script here to accomplish that -> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/416087

As well you could try a registry approach

Environment variable
http://community.installshield.com/showthread.php?t=135637
http://community.installshield.com/showpost.php?p=286326&postcount=5

#define WM_SETTINGCHANGE 0x001A
#define WM_WININICHANGE 0x001A
#define HWND_BROADCAST 0xffff

SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,rEnv);

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";

//"Successfully Updated Environment Variable
// Flush the NT registry to all applications.
szEnv = "Environment";
pEnv = &szEnv;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );


Environment Variable Not Showing Until Reboot
http://community.installshield.com/showthread.php?t=144747

You can do the registry manipulation probably, but realize you also need to call SendMessage to broadcast the settings change. This is really old school ISPro5 approach.

System Env data is stored at:

HKLM\SYSTEM \CurrentControlSet\Control\Session Manager\Environment




 
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20965906
Forced accept.

Computer101
EE Admin
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now