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";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Get Default Printer on NT4 (boo)
by boo_radley (Parson) on Aug 27, 2001 at 22:09 UTC | |
Re: Get Default Printer on NT4
by jryan (Vicar) on Aug 28, 2001 at 19:00 UTC | |
by mrmick (Curate) on Aug 28, 2001 at 19:28 UTC | |
by Anonymous Monk on Sep 08, 2001 at 07:13 UTC | |
by Anonymous Monk on May 24, 2002 at 14:23 UTC |
Back to
Cool Uses for Perl