regedit changes to environment variable not taken into aco..

G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

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
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More 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
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

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...
 

blackadder

Distinguished
Jul 20, 2005
30
0
18,530
Archived from groups: microsoft.public.windowsxp.customize (More info?)

<perso.lehalle@gmail.com> wrote in message
news:1122473186.756957.250230@o13g2000cwo.googlegroups.com...
> 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.
 

blackadder

Distinguished
Jul 20, 2005
30
0
18,530
Archived from groups: microsoft.public.windowsxp.customize (More info?)

"cal" <perso.lehalle@gmail.com> wrote in message
news:1122477965.745778.276460@g43g2000cwa.googlegroups.com...
> 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).
 

blackadder

Distinguished
Jul 20, 2005
30
0
18,530
Archived from groups: microsoft.public.windowsxp.customize (More info?)

"cal" <perso.lehalle@gmail.com> wrote in message
news:1122480233.207231.140140@g43g2000cwa.googlegroups.com...
> 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.
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

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


<perso.lehalle@gmail.com> wrote in message
news:1122473186.756957.250230@o13g2000cwo.googlegroups.com...
> 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
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

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
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

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
>
>
> <perso.lehalle@gmail.com> wrote in message
> news:1122473186.756957.250230@o13g2000cwo.googlegroups.com...
> > 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
> >
>
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

On Fri, 29 Jul 2005 08:01:05 -0700, "Herve"
<Herve@discussions.microsoft.com> wrote:

>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.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"My theory was a perfectly good one. The facts were misleading."
-- /The Lady Vanishes/ (1938)
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

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


"Herve" <Herve@discussions.microsoft.com> wrote in message
news:7345C71F-EF5B-404D-BD4B-F0F145B43EB5@microsoft.com...
> 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
>>
>>
>> <perso.lehalle@gmail.com> wrote in message
>> news:1122473186.756957.250230@o13g2000cwo.googlegroups.com...
>> > 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
>> >
>>
>>
>>