2016-04-23 00:32
浏览 93


I'm trying to develop a way to pull a list of printers (names and IPs at least), from a Windows print server. I plan to use this info in an external PHP-driven status website, running on a Linux webserver, which talks to the printers individually via SNMP. The SNMP communication is already functional. I just need a way of dynamically generating the list of printers it talks to, instead of hard coding all of the IPs/DNS Hostnames.

The idea here is that I do this entirely without touching or changing the print server(s), printers, or the underlying webserver. The only thing under my control is a shared, non-administrative CPanel account.

My research so far has led me to three potential leads. I have next to no experience with any of them.

1) The PHP printer_list command, which is part of the PECL extension. At the moment our webserver does not have this extension installed, and I'd prefer not to make that request unless I know it will work for my purposes.

2) The lpstat Linux command, part of CUPS. I've tried using it per the man page and it seems to just sit there doing nothing. I don't know if this is because it's expecting a CUPS response which I figure it will not be getting from a Windows server, or if this might be a firewall issue.

3) SMB or WMI queries of some sort. I have no idea how to even begin with these.

I'd like to ask for a recommendation on where to start. This has been a very troubling project to research because 90% of search results are about people wanting to print. Another 8% are about people polling a local system for printer info. The rest are black magic and proprietary enterprise solutions.

Any insights are very much appreciated. == Matt

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongtui6347
    dongtui6347 2016-04-23 21:43

    I am using WMI effectively to fetch printer information over network using :

    Select * FROM Win32_Printer

    To begin:

    1 - Run wbemtest from run window.

    2 - Connect to any machine where you know printers are configured.

    3 - There is query option, copy Select * FROM Win32_Printer

    4 - Step 4 will return you table, click on Show MOF, it will provide you printer information. Viola, you are done.

    5 - I have used C# ManagementObjectSearcher & ManagementObjectCollection and it is pretty straightforward and easy to use.

    There are some pros and cons of using WMI. Read it online.

    点赞 评论