Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Thin secure Windows 10 5 107
Use CRON to save a copy of an open file 1 70
Wants to Upgrade fro Vista to Windows 10 9 70
Nimble Storage 3 135
Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
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…
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.

762 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