Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: WinNT Printer monitoring...

by rchiav (Deacon)
on Sep 05, 2001 at 15:52 UTC ( #110257=note: print w/replies, xml ) Need Help??


in reply to WinNT Printer monitoring...

It's funny that you should ask this. I'm currently working on a Perl program that will allow somone to administer printers. When done, it will work for NT and Novell without having to install the driver or map to the printer.

What I'm using (and what you're going to want to look at) is ADSI. Specifically, look at this page. Scroll down till you see IADsPrintQueue and IADsPrintQueueOperations. You'll use Win32::OLE to access these.

Let me know if you need an example and I'll throw one together.

Hope this helps..
Rich

Replies are listed 'Best First'.
Re: Re: WinNT Printer monitoring...
by Necos (Friar) on Sep 05, 2001 at 22:26 UTC
    ASDI seems like a nice option. However, that means upgrading my domain to Active Directory (to be able to access the API), which I don't really trust. I know Microsoft has done a lot to AD since the launch of WinNT 5, but it's not something I want to bet my car and college on. I'd be a little more interested in a Win32::API(EnumPrinters()) call (I just got a chance to look at the MSDN Printer reference that was pointed out). This would be a much nicer thing to do (albeit possibly slower) since it would be backwards compatible (I have a thing for backwards compatibility). Maybe I'm just being harsh on Active Directory, but oh well. Thanks for the lead though. It's definitely worth a shot.

    Necos
    secon_kun@hotmail.com
      No, you don't have to upgrade to 2000. There's the "WinNT://" service providor which works just fine for NT machines. That link I gave you includes what objects are available to which service providors. You can even interface the entire Novell NDS structure (OU's, users, printers, etc..)

      Here's a little sample. This will list the names of printers on a praticular NT server..

      !/usr/bin/perl -w use strict; use Win32::OLE qw/in/; #fill in domain and server my $domain = ''; my $server = ''; my $printer; my $objServer = Win32::OLE->GetObject("WinNT://$domain/$server"); $objServer->{FILTER} = ["printqueue"]; foreach $printer (in $objServer) { print "$printer->{NAME}\n"; }
      Hope this helps..
      Rich
        Hmmm... This is really interesting. As much as I praise the Windows 2000 workstation edition, I'm still new to the Win2k (Active Directory, etc.) scheme of things. Personally, I find it very unstable. However, since you're using Win32::OLE to get the server information, there could be some pretty code down the line. I'd still like to use Win32::API (since it's backwards compatible with 95/98, which some of our workstations still run) to write a module (since one hasn't been written, or, at least, none of us know about it). I'm assuming that the code you're writting will be closed source. I've always been a personal fan of OSS and if I do get an opportunity to write a GOOD module for Win32 printer monitoring, I'd definitely be releasing the code under GPL (and if you do make your code closed, I hope it sells well, cause it's awful clever of you to use ASDI, something which is completely foreign to me). One thing that I wanted to ask however, which DLL contains the printer and spooling functions that are described in SDK? Microsoft says its in the SDK, but I'm pretty sure the DLL has to be local since the Spooler service can monitor the ports.

        Necos
        secon_kun@hotmail.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://110257]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-09-22 23:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?