How to add a permanent environment variable ?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
budhax
Posts: 59
Joined: 09 Oct 2006 12:25

How to add a permanent environment variable ?

#1 Post by budhax » 10 Feb 2007 15:30

How to add a permanent environment variable ? (using a .BAT or .REG file)

Hello,
I read this http://www.ss64.com/nt/set.html (under "Permanent Changes") and
I added a permanent environment variable using a add_myvar.reg file like this:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
"myvar"="coucou"

Now I can see myvar going in Registry Editor under
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]

And I can see myvar going to: MYCOMPUTER (right-click) > Properties > Advanced tab > Environment Variable > System variables.

But, myvar is not listed using the SET command in the DOS command line, so I cannot use myvar in batch file.
What wrong? Do you have any idea?

PS
I have the same problem adding myvar in "Current user variables"
i.e. in [HKEY_CURRENT_USER\Environment]
i.e. in MYCOMPUTER (right-click) > Properties > Advanced tab > Environment Variable > User variables.

I would add (permanently) this environment variable, without using SETX command. Is it possible ?
SETX command is not available on my DOS window. Should I get and add SETX.exe somewhere in my system?


CONFIG: MS Windows XP Pro SP2
Thanks

budhax
Posts: 59
Joined: 09 Oct 2006 12:25

#2 Post by budhax » 10 Feb 2007 16:32

All fine if I reboot my system ;)

Post Reply