Solved

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

Posted on 2007-12-06
4
3,350 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
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…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

786 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