|| 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.
or die "Can't open this key: $^E";
my ($type, $value);
$pval->QueryValueEx("Device", $type, $value) or die "No Device Found:
print "Here's the default printer for this user: $value\n";