Solved

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

Posted on 2007-12-06
4
3,412 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
#Citrix #POC #XenDesktop #vCenter #VMware #ESX
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Suggested Courses

630 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