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

I posted a question before about adding environment variables and i got a lot of fast responses. YOU GUYS ROCK! but i was not clear on what kinda help i needed. I am trying to add a system environment variable on a few remote machines with a certain name and a certain value. Would i still use the TieRegistry module? and how does the actual syntax go? any examples and help would be greatly appreciated. ~A beginner in Search of Perl Wisdom~ Ray

Replies are listed 'Best First'.
Re: actual sys environment variables
by particle (Vicar) on Jul 05, 2001 at 22:56 UTC
    this snippet will set a new system environment variable named bob. if you want to create a user environment variable, use the commented out code instead. make sure you understand the difference before you do this blindly. a system environment variable will affect all users on that machine. a user environment variable will affect only that specific user.
    #!/usr/bin/perl -w use strict; my $Reg; use Win32::TieRegistry ( TiedRef => \$Reg, ArrayValues => 1, Delimiter => '/', ':REG_' ); # this is the system environment variable area my $SysEnv= $Reg->{"LMachine/System/CurrentControlSet/Control/" . "Session Manager/Environment/"} or die "Can't open Registry key, Session Manager/Environment: $^E +\n"; # create a new value and set it's data $SysEnv->{"/bob"} = "test system"; # # this is the user environment variable area # my $UserEnv= $Reg->{"CUser/Environment/"} # or die "Can't open Registry key, CUser/Environment: $^E\n"; # # create a new value and set it's data # $UserEnv->{"/bob"} = "test user";
    thanks to tye, as most of this code is pasted from his example here.

    ~Particle

      thnx. I do know the difference in the two env vars as i am an NT sys admin. Your help is much appreciated.