Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

windows environment variable regression

by mpersico (Beadle)
on Aug 12, 2013 at 18:24 UTC ( #1049159=perlquestion: print w/ replies, xml ) Need Help??
mpersico has asked for the wisdom of the Perl Monks concerning the following question:

Using the Win32::TieRegistry, I did:

$env->SetValue('PERL_PATHS', $new_dirs)

where $new_dirs contains the new paths for strawberry perl.

I then did

$path = "$path;\%PERL_PATHS\%"; $env->SetValue('Path', $path);

and then rebooted the machine. In a command window, PERL_PATHS was set properly, but PATH looked like

Path=C:\Sybase\DBISQL\bin;C:\Sybase\DataAccess64\...;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;%PERL_PATHS%

i.e.; no expansion. I then went into the Environment Variables dialog, deleted %PERL_PATHS% from PATH, saved, when back in, added it again and when I looked at PATH in a new command window, I got the expansion.

Does anyone know what else you have to do programmatically besides add a variable to another variable to get expansion to occur? Thanks

Comment on windows environment variable regression
Select or Download Code
Re: windows environment variable regression
by BrowserUk (Pope) on Aug 12, 2013 at 18:48 UTC
    Does anyone know what else you have to do programmatically besides add a variable to another variable to get expansion to occur?

    Environment variable expansion is a function of the shell. You are not involving the shell when you write directly to the registry, thus it does not occur.

    If you want these directories in the path, add them to the path.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Yes, in *NIX land. However, I should be able to write to the registry and have subsequent shells pick up my changes. And it ALMOST works. If I write directly to the PATH, no issues. If I write the PERL_PATH variable and stick it into the PATH, then subsequent shells do NOT expand PERL_PATH in PATH. If, however, all I do is fire up the Environment Variable dialog, see that all my changes are there and then click OK (no editing, no updates), the NEXT command box has the expansion properly done. That leads me to believe that there's some other 'bit' that has to be flipped. I'll have to test by looking at the registry directly which I cannot do on the current box. More to follow.
        Yes, in *NIX land.

        I'll take your word for that as I know next to nothing about *nix.

        On the other hand I've used and programmed every version of NT since 3.51 except 7 and rt.

        If, however, all I do is fire up the Environment Variable dialog ...

        That dialog is a part of the windows graphical shell. The alternative shell to cmd.exe.

        After you've used that dialog and the %perl_path% has been expanded, check the path variable in the registry. It will no longer contain %perl_path%; it will have been replaced by the expansion.

        So why not just put the directories into the path variable to start with?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: windows environment variable regression
by Jim (Curate) on Aug 12, 2013 at 22:00 UTC

    This is a total shot in the dark, with no real basis besides intuition and alacrity. Try this instead:

    $path = "$path;\%\%PERL_PATHS\%\%";

    (Untested.)

    Nah, that won't work. Try this instead:

    $env->SetValue('PERL_PATHS', $new_dirs) $path = "$path;$new_dirs; $env->SetValue('Path', $path);
        I'll give that a shot, too.
      I'll give that a shot.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1049159]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2014-12-18 05:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (42 votes), past polls