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.


In reply to how do you propagate Tie::Registry modifications to the system environment by warrendodge

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.