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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器