Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm new to Perl/TK. I'm working on a Win2k system and trying to permanantly change the environment variables. I have tried the command:

sytem ("set HDS_TEAM_HOME = C:\\BATC_APPS\\Team_Flight");

but this seems to only set this during the execution of the script. Is there a way to permanantly set this? Thanks, Rob Morrow rmorrow@ball.com

Replies are listed 'Best First'.
Re: Modifying Win2K environment variables
by halley (Prior) on Aug 14, 2003 at 19:19 UTC
    The portable and preferable way to set an environment variable for the current process, and any children spawned thereafter:
    $ENV{HDS_TEAM_HOME} = "C:\\BATC_APPS\\Team_Flight";

    On Windows, the shell (CMD.EXE or COMMAND.EXE) does not communicate behind the scenes, as Un*x shells often do. To alter environment variables for unrelated processes, you have to poke values into pseudo-registry keys. Check out CPAN for Win32::TieRegistry and the docs should help.

    --
    [ e d @ h a l l e y . c c ]

      And for some examples of setting environment variables both permanently (in the registry) and in the parent shell at the same time, check out the (updated) CleanPath. (:

                      - tye
Re: Modifying Win2K environment variables
by particle (Vicar) on Aug 14, 2003 at 19:55 UTC
Re: Modifying Win2K environment variables
by fourmi (Scribe) on Aug 15, 2003 at 13:33 UTC
    typo? should be system