my $winpath = $ENV{windir}; # Returns C:\WINDOWS or whatever #If you prefer systemroot , my $sysroot=$ENV{SystemRoot};