answersLogoWhite

0

Assuming you are asking how to do this by hand and not from a program, see below. If you want to write a program you'll need to look on MSDN for the various ways of setting and retrieving environment variables.

Set your environment variables into the registry using REG.EXE from the command line.

Variables for the Current User are stored in HKEY_CURRENT_USER (HKCU) and for All Users in HKEY_LOCAL_MACHINE (HKLM). The registry locations are:

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

You'll need to know the type of data you want to store. Choices are:

  • REG_SZ
  • REG_MULTI_SZ
  • REG_DWORD_BIG_ENDIAN
  • REG_DWORD
  • REG_BINARY
  • REG_DWORD_LITTLE_ENDIAN
  • REG_NONE
  • REG_EXPAND_SZ

So to create an environment variable named "Fred" with a value of "1234" do this:

REG ADD HKCU\Environment /v Fred /d 1234 /t REG_SZ

/v is the variable, /d is the data and /t is the type. Use REG_EXPAND_SZ if you want to include existing environment variables (e.g. %system%) and remember to double the %'s (i.e. \d %%system%%\mypath.

Retrieve your setting with:

REG QUERY HKCU\Environment /v FRED

NOTE: This will not update the current environment, neither in the current command window nor in other windows (of any type). ou must logout and login for the changes to be picked up r you'll need to compile the following code-lette which I got from the MSDN reference:

#include

int main(int argc, char* argv[])

{

DWORD_PTR dwReturnValue;

SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,

(LPARAM) "Environment", SMTO_ABORTIFHUNG,

5000, &dwReturnValue);

return 0;

}

Type REG at a command prompt for more details.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What is the purpose of PATH variable in Linux?

It's an environment variable that stores the paths of commonly used executables. All OSes have this set, even on Windows.


Where is the path variable in ms-dos environment?

It's called Path (use the SET command to access it).


How do you set path in java?

1. install JdK 2. include JDK_HOME/bin in your PATH environment variable


How do you find out the type of unix shell you are using?

The name of your login shell is set when you log in - check the $SHELL environment variable. Note that this is a changeable environment variable so it isn't always accurate. You could also use the 'finger' command or 'grep' through the password file to see what your login shell environment will be set to. However, if you are in a subshell or child shell, you will need to check on the shell environment with the 'ps' command to see what the shell currently running might be.


How do I set up my Wal-Mart wedding registry?

To set up a Wal-Mart wedding registry you can either go to any Wal-Mart store and visit the customer service station. They will set you up with everything you need. Or you can visit Walmart.com. On the front page click on the "Registry" tab at the top of the page. Then select "Create Wedding Registry". From here you will have to set up a Wal-Mart account, if you already do not have one, after that it's as easy as selecting items from the website and adding them to your registry. After creating a registry online, you will also be able to go to any physical Wal-Mart store and add items to the registry.


A set of data involving one variable?

A set of data with one variable is a net-graph


How can a honeymoon registry be done?

A honeymoon registry involves collecting gifts from wedding guests. There are online web services that can help one set up a honeymoon registry, such as Honeyfund and Honeymoon Wishes.


How do you set up a bridal registry with Macy's?

You set up a Macy's bridal registry by going to their official site and registering. You pick the items you want and add them to your list. Then you give out the list to all attendees.


How do you set Linux sudo permissions?

By carefully editing the /etc/sudoers file using visudo.Note: before that set environment variable EDITOR to your favourite text-editor, for example:export EDITOR=/usr/bin/mcedit


What does it mean if the mean is doubled but the standard deviation is the same?

The second set of numbers are less variable; the coefficient of variation is halved. The second set of numbers are less variable; the coefficient of variation is halved. The second set of numbers are less variable; the coefficient of variation is halved. The second set of numbers are less variable; the coefficient of variation is halved.


Is the value of a variable for an element called data set?

The observed values of a variable form the data set. Not sure where "element" fits into it.


How do you set up a wedding registry at Willams and Sonoma?

Creating a wedding registry at Williams and Sonoma is simple. First go to http://www.williams-sonoma.com. Under the registry tab at the top left corner of the homepage, select "Create your Registry." Fill out the fields on the form and then select the items you would like to include in your registry.