use strict; use warnings; my $Registry; use Win32::TieRegistry ( Delimiter => "/", TiedRef => \$Registry, "REG_EXPAND_SZ" ); use Win32::API; my $dir = "c:\\another_directory"; # Registry key for $ENV{PATH} my $path_key = "LMachine/SYSTEM/CurrentControlSet/Control/Session Manager/Environment/Path"; die "Can't find Path registry key\n" unless exists $Registry->{$path_key}; my $path = $Registry->{$path_key}; $path .= ";$dir"; $Registry->{$path_key} = [ $path, REG_EXPAND_SZ ]; use constant HWND_BROADCAST => 0xFFFF; use constant WM_SETTINGCHANGE => 0x001A; my $SendMessage = Win32::API->new("user32", "SendMessage", [qw(N N P P)], "N"); my $result = $SendMessage ->Call(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 'Environment');