#/usr/bin/perl -w use strict; my $Reg; use Win32::TieRegistry ( TiedRef => \$Reg, ArrayValues => 1, Delimiter => '/', ':REG_' ); my( $Host, $Key, $Value )= @ARGV; # Asking for machine name and info to be added to the sys env var if( ! defined $Host ) { print "What host would you like to connect to? "; $Host= or exit; chomp $Host; } if( ! defined $Key ) { print "What name would you like for the Sys Environment Variable? "; $Key= or exit; chomp $Key; } if( ! defined $Value ) { print "What value would you like to assign to this variable? "; $Value= or exit; chomp $Value; } # this is the system environment variable area done on the registry my $SysEnv= $Reg->Connect("$Host", "LMachine/System/CurrentControlSet/ +Control/Session Manager/Environment/") or die "Can't connect to $Host 's registry or can't open Registry + key, Session Manager/Environment: $^E +\n"; # create a new value and set its data $SysEnv->{"/$Key"} = [ $Value, REG_EXPAND_SZ ] or die "Can't create $Key ($Value): $^E\n";