regedit changes to environment variable not taken into acount

  • Thread starter Thread starter perso.lehalle
  • Start date Start date
P

perso.lehalle

Hi

I uses command line
regedit /s myhome.reg
where the file myhome.reg is:
==== myhome.reg ====
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Environment]
"HOME"="G:\\Recherche_ST\\Charles\\textes\\"
==== END OF FILE ====

then I open a cmd.exe shell and try:
echo %HOME%
it seems that the environment variable is not set...

BUT if I go to the env var panel of the advanced / system dialog, I see
that the HOME env var is set...
If I press OK in this panel, then it is available in a cmd.exe shell...

can someone tell me how to activate this change from the command line?

thanx
charles
 
Hi

I uses command line
regedit /s myhome.reg
where the file myhome.reg is:
==== myhome.reg ====
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Environment]
"HOME"="G:\\Recherche_ST\\Charles\\textes\\"
==== END OF FILE ====

then I open a cmd.exe shell and try:
echo %HOME%
it seems that the environment variable is not set...

BUT if I go to the env var panel of the advanced / system dialog, I see
that the HOME env var is set...
If I press OK in this panel, then it is available in a cmd.exe shell...

can someone tell me how to activate this change from the command line?

From a command line:

SET HOME=G:\Recherche_ST\Charles\textes\

Type SET/? for syntax info.
 
thanks but NO
set HOME will not change the global HOME environment variable, its only
for the current cmd.exe shell.
execute your command and go to the system/advanced/env var panel and
you will see than you did not change anything.
execute mine, and the result will be different (remind the original
value of your HOME env var before if you have one)
charles
 
cal said:
thanks but NO
set HOME will not change the global HOME environment variable, its only
for the current cmd.exe shell.
execute your command and go to the system/advanced/env var panel and
you will see than you did not change anything.
execute mine, and the result will be different (remind the original
value of your HOME env var before if you have one)
charles

If you want it in the current CMD shell and as a permanent environment
variable then you should do both (use SET and merge your REG file).
 
the problem is that it does NOT work...
try someting like:
regedit /s test.reg
with test.reg like:
==== test.reg ====
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Environment]
"GARBURE"="garzol"
==== END OF FILE ====

then open ANOTHER cmd.exe and type:
echo %GARBURE%
and see the result...

then open the system/advanced/env-var panel: the GARBURE var will be
there, but innefficient.
click on the OK button of this panel and open another new cmd.exe, type
again:
echo %GARBURE%
and see the result...

so strange...
 
cal said:
the problem is that it does NOT work...
try someting like:
regedit /s test.reg
with test.reg like:
==== test.reg ====
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Environment]
"GARBURE"="garzol"
==== END OF FILE ====

then open ANOTHER cmd.exe and type:
echo %GARBURE%
and see the result...

then open the system/advanced/env-var panel: the GARBURE var will be
there, but innefficient.
click on the OK button of this panel and open another new cmd.exe, type
again:
echo %GARBURE%
and see the result...

so strange...

Sorry, I obviously wasn't clear enough.

The correct way to create a permanent envirnment variable is to use the
System | Advanced | Environment Variables dialog. Merging a REG file will
NOT update the shell -- hence you have to OK the dialog after merging.

To make an environment variable take immediate effect, simply use SET from
the command shell. You'll obviously have to repeat this for every command
shell -- unless you use the correct method as stated above.
 
If you want to change environment variables (system or user specific) and to
have changes to take effect without new logon, you have to generate specific
windows message:

WinSendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)NULL,
(LPARAM)"Environment");

That message tells Explorer (and perhaps other applications too) that
environment variables have changed. Still, if you have open command prompt,
you have to reopen it before changes are visible. That's because cmd.exe
doesn't react that message and update variables. I don't know how to
generate that message without a program, but perhaps it it is possible from
vbscript? I have used it from c/c++ program, which can change system or user
environment variables from command line or script.

Nico


Hi

I uses command line
regedit /s myhome.reg
where the file myhome.reg is:
==== myhome.reg ====
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Environment]
"HOME"="G:\\Recherche_ST\\Charles\\textes\\"
==== END OF FILE ====

then I open a cmd.exe shell and try:
echo %HOME%
it seems that the environment variable is not set...

BUT if I go to the env var panel of the advanced / system dialog, I see
that the HOME env var is set...
If I press OK in this panel, then it is available in a cmd.exe shell...

can someone tell me how to activate this change from the command line?

thanx
charles
 
thank you,
it's exactly what I wanted, but I use a shell command, so I think I
won't be able to use that...
charles
 
Does anybody know how to genrate the

WinSendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)NULL,
LPARAM)"Environment");

message from VBScript ?

Thank.
Herve

"News Reader" a écrit :
If you want to change environment variables (system or user specific) and to
have changes to take effect without new logon, you have to generate specific
windows message:

WinSendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)NULL,
(LPARAM)"Environment");

That message tells Explorer (and perhaps other applications too) that
environment variables have changed. Still, if you have open command prompt,
you have to reopen it before changes are visible. That's because cmd.exe
doesn't react that message and update variables. I don't know how to
generate that message without a program, but perhaps it it is possible from
vbscript? I have used it from c/c++ program, which can change system or user
environment variables from command line or script.

Nico


Hi

I uses command line
regedit /s myhome.reg
where the file myhome.reg is:
==== myhome.reg ====
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Environment]
"HOME"="G:\\Recherche_ST\\Charles\\textes\\"
==== END OF FILE ====

then I open a cmd.exe shell and try:
echo %HOME%
it seems that the environment variable is not set...

BUT if I go to the env var panel of the advanced / system dialog, I see
that the HOME env var is set...
If I press OK in this panel, then it is available in a cmd.exe shell...

can someone tell me how to activate this change from the command line?

thanx
charles
 
You cannot do it with vbscript. There are no functions or methods to handle
windows messages.


Herve said:
Does anybody know how to genrate the

WinSendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)NULL,
LPARAM)"Environment");

message from VBScript ?

Thank.
Herve

"News Reader" a écrit :
If you want to change environment variables (system or user specific) and
to
have changes to take effect without new logon, you have to generate
specific
windows message:

WinSendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)NULL,
(LPARAM)"Environment");

That message tells Explorer (and perhaps other applications too) that
environment variables have changed. Still, if you have open command
prompt,
you have to reopen it before changes are visible. That's because cmd.exe
doesn't react that message and update variables. I don't know how to
generate that message without a program, but perhaps it it is possible
from
vbscript? I have used it from c/c++ program, which can change system or
user
environment variables from command line or script.

Nico


Hi

I uses command line
regedit /s myhome.reg
where the file myhome.reg is:
==== myhome.reg ====
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Environment]
"HOME"="G:\\Recherche_ST\\Charles\\textes\\"
==== END OF FILE ====

then I open a cmd.exe shell and try:
echo %HOME%
it seems that the environment variable is not set...

BUT if I go to the env var panel of the advanced / system dialog, I see
that the HOME env var is set...
If I press OK in this panel, then it is available in a cmd.exe shell...

can someone tell me how to activate this change from the command line?

thanx
charles
 
Does anybody know how to genrate the

WinSendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)NULL,
LPARAM)"Environment");

message from VBScript ?

Herve,

This may be overkill for you, but the 4NT command shell replacement
can set environment variables in the current command shell and the
Registry and any later command shells, all with one command
set /u /e name=value
Presumably it does this by sending that Windows message among other
things.

I use this 4nt.exe replacement for the cmd.exe command shell myself.

It's a free 30-day trial but after that must be paid for --
jpsoft.com for details.
 
Back
Top