warrendodge has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to use Tie::Registry to make changes to the registry. I can
do that just fine. But what I want is that those changes be made
available to all the current environment of windows so that the next
application that is executed will see the changes.
Here is the script I am trying.
-----------------------------------------------------------------------------
use Win32::TieRegistry ( Delimiter=>"/");
$Registry->{CUser}->{Environment}->{XXX} = "YYY";
-----------------------------------------------------------------------------
In the current "cmd" window the XXX variable is not in the environment
after executing the script. This I expect.
Using regedit you can see the XXX variable has indeed been set in the
registry.
Start->run->cmd This new command window does not see the XXX variable
either. But I expected it would.
We had been using The Win32::AdminMisc package in the past and it
operated as I would expect. However, I haven't been able to bring it
forward to later versions of perl. In looking at that C code I found
this routine which was executed after each variable setting.
DWORD dwMessageResult = 0;
SendMessageTimeout( HWND_BROADCAST,
WM_WININICHANGE,
0,
(LPARAM) "Environment",
SMTO_ABORTIFHUNG,
dwTimeout,
&dwMessageResult );
I believe this will signal all the processes that they should update
their environment variables from the registry.
We have also found that using the command "setx" we can cause the
changes to the registry to be sent to all the processes. Currently we
are using this method: setx x x and set a dummy variable.
What I am looking for is a "more refined" way to do this. It would be
really nice if Tie::Registry could provide a function/param to cause
changes to be seen by the environment.
Any help in this area will be greatly appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how do you propagate Tie::Registry modifications to the system environment
by Khen1950fx (Canon) on Jul 22, 2010 at 06:46 UTC | |
by warrendodge (Initiate) on Aug 13, 2010 at 17:47 UTC | |
by tye (Sage) on Aug 14, 2010 at 06:02 UTC | |
by warrendodge (Initiate) on Aug 16, 2010 at 21:34 UTC | |
by tye (Sage) on Aug 16, 2010 at 21:38 UTC | |
|