#!/usr/bin/perl -w =pod This script adds paths into the system path. Simply change @newpaths to reflect the directories you'd like to add. Author: P. Rivera Portions inspired by: Marza/Perlmonks, node 156805; Zaxo and various monks, node 190779 =cut use strict; my $Registry; my $newpath; my @newpaths=('P:\Scripts\Admin','P:\Scripts\Anly','P:\Perl\bin'); use Win32::TieRegistry ( TiedRef=>\$Registry, Delimiter=>"/", ArrayValues=>1 ); my $env= $Registry->{"LMachine/System/CurrentControlSet/Control/". "Session Manager/Environment/"} or die "Can't open CCS/SM/Env: $^E\n"; my $path= $env->{"/PATH"} or die "Can't get PATH: $^E\n"; print "Path currently is $path->[0]\n\n"; print "-" x 65 . "\n"; for $newpath (@newpaths) { print "Attempting to prepend $newpath to path.\n\n"; #See if new path is the system PATH if ($path->[0] =~ /\Q$newpath\E/ ) { print "$newpath is already in your system PATH. Not added again.\n"; } else { $path->[0]= $newpath . ";$path->[0]"; print "Path is now $path->[0]\n\n"; $env->{"/PATH"}= $path or print "Can't set PATH!!: $^E\n"; } print "-" x 65 . "\n"; }