doudong7256 2016-04-23 00:32
浏览 102
已采纳

从Windows打印服务器轮询打印机信息

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 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Java中消息和缓存如何使用
  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路