http://qs321.pair.com?node_id=108152
Description: A colleague of mine needed a way to find out what is set as the default printer for many NT4 workstations, so that he could modify static settings for some of the 3rd party software packages that we distribute. Most people are connected to network printers, although there are a few who have their own local printer.

I had to do a lot of searching (web searches) and, through trial and error, I finally came up with the following solution. It's not perfect but seems, in our environment, to be reliable with testing on several machines in different locations.

I know that Win32::Registry is considered to be obsolete, but it does the job well for this purpose.

use Win32::Registry;
use strict;

my $pval;

$::HKEY_CURRENT_USER->Open("SOFTWARE\\Microsoft\\Windows NT"
                               ."\\CurrentVersion\\Windows", $pval)
        or die "Can't open this key: $^E";

my ($type, $value);
$pval->QueryValueEx("Device", $type, $value) or die "No Device Found: 
+$^E";
print "Here's the default printer for this user: $value\n";