Re: Win32::Printer::Enum::Printer($server)



> Thomas Kratzwrote:

>
> I tend to use WMI these days. You might want to try this:
> .
> .
> .
> .
>

Thomas,

I am trying to adjust your code, which I think will solve my problem
(Thanks, I was going crazy!) but I am a little lost as to how I might
adjust it to email me if one of the queues error.

the $attrib returns the column heading rather than the data from the
array.

I'm sure I am missing something simple but my brain has overheated. .
..

Here is what I have so far:

#use strict;
use warnings;

use Win32::OLE qw/in/;
Win32::OLE->Option(Warn => 1);

$ARGV[0] ||= '';

my $wmi =
Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate,(security)}$ARGV[0]")
or die "error initializing WMI interface, ",

Win32::OLE->LastError;

my @attrib = qw/DeviceID Status/;

print join(', ', @attrib), "\n";
for my $p ( in($wmi->InstancesOf('Win32_Printer')) ) {
$_ ||= '' for @$p{@attrib};
print join(', ', @$p{@attrib}), "\n";

if($attrib[1] ne Error)

{
# system("D:/\\server/share/\\dir/\\frmsendmail.exe blank\.txt -t
me\@mine.com -priority 1 -subject a_printer_has _a_problem");
}

}

.



Relevant Pages

  • RE: Which table is used to store the polling interval of rec Loc
    ... Using WMI to adjust these properties is supported. ... Which table is used to store the polling interval of rec Loc ...
    (microsoft.public.biztalk.general)
  • WMI Query Permissions
    ... I'm fairly new to WMI. ... works like a charm from an administrator account, ... Alternatively, if I need to adjust the user's privilege level, what do ...
    (microsoft.public.win32.programmer.wmi)