Deane, try these lines of Perl for WMI:

use Win32::OLE qw(in with);

$WMI = Win32::OLE->new('WbemScripting.SWbemLocator');
$Services = $WMI->ConnectServer("", "root/cimv2");
my $Printer_set = $Services->InstancesOf("Win32_Printer");
                
foreach my $object (Win32::OLE::Enum->All($Printer_set)) {
        print "Caption: $object->{'Caption'}\n";
        print "Device ID: $object->{'DeviceID'}\n";
        print "Local: $object->{'Local'}\n";
        print "Network: $object->{'Network'}\n";
        print "PortName: $object->{'PortName'}\n";
        print "Status: $object->{'Status'}\n";
}

This gives me the output below.  Does this help you any?
Scott

OUTPUT
------
Caption: Microsoft XPS Document Writer
Device ID: Microsoft XPS Document Writer
Local: 1
Network: 0
PortName: XPSPort:
Status: Unknown
Caption: Microsoft Office Document Image Writer
Device ID: Microsoft Office Document Image Writer
Local: 1
Network: 0
PortName: Microsoft Document Imaging Writer Port:
Status: Unknown
Caption: \\pwm13tms1\CS025790 - color printer
Device ID: \\pwm13tms1\CS025790 - color printer
Local: 0
Network: 1
PortName: 10.78.55.231
Status: Degraded

________________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, May 07, 2008 10:35 AM
To: [email protected]
Subject: Finding a printer; need help


Gurus, 

Anybody know of a Perl module that can tell me 1. If there's a printer 
physically connected to a parallel (or serial) port on a PC and, 2. what 
printer it is? I've got a project that wants this info, and I've pretty much 
gotten nowhere trying to use WMI (unless I've missed something). In one 
instance, it (WMI) identifies seven printers connected to LPT1:, and says that 
all of them are in "Idle" status. Anybody want to assess the accuracy of that 
result?  I know, it's just reading the registry (I think); so the information I 
need must be elsewhere. 

True confession time: I'm at a loss here, and in need of your guidance. 

Thanks!!!!!!! 

Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
847-914-5150

There is something fascinating about science. One gets such wholesale returns 
of conjecture out of such a trifling investment of fact. -- Mark Twain

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to