如何检测何时需要打印机驱动程序? [英] How can I detect when a printer driver is needed?

查看:97
本文介绍了如何检测何时需要打印机驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个计划任务,该任务使用打印机的UNC路径将文档打印到各种打印机.最近,添加了新的打印机UNC路径,但是执行计划任务的系统缺少适当的驱动程序 打印到该打印机.由于该进程是作为计划任务运行的,因此当我尝试在我的贷方下运行该任务时,通常弹出的要求安装驱动程序的窗口被抑制.这项任务似乎没有任何解释就被搁置了. 直到我在用于安装计划任务的信用凭证下登录后,该窗口才会弹出.看到窗口后,我就安装了驱动程序,并且一切正常.但是,如果再次发生这种情况,我想 能够捕获安装驱动程序和发送电子邮件的需求,并在应用程序日志中记录需求.这将帮助其他人更快地解决问题,因为大多数人登录到运行该任务的机器时都使用自己的信用凭证,而不是 而不是用于安装任务的计算机.可以这样做,如果可以,有人可以提供有关如何执行此操作的代码段吗?

I have a scheduled task that prints documents to various printers using the printer's UNC path.   Recently, a new printer UNC path was added but the system which executes the scheduled task lacked the appropriate driver to print to that printer.  Since the process runs as a scheduled task, the window that normally pops asking to install a driver was suppressed when I tried running the task under my creditials.  The task just seemed to hang without explaination.  It wasn't until I logged in under the creditials used to install the scheduled task, that the window popped up.  Once I saw the window, I installed the driver and all is working.  However, should this happen again, I would like to be able to capture the need to install the driver and send out an email as well as log the need in the application log.  This will help others more quickly troubleshoot the issue as most log into the box running this task under their own creditials rather than the one used to install the task.  Can this be done and if so, can someone provide a code snippet on how to go about doing it?

谢谢

推荐答案

您好,

谢谢用于发布.

根据您的描述,我认为我们应该确保要使用哪种打印机型号/打印机驱动程序.因此,我们首先想到的是 检查如何实现此驱动程序.如果您发现哪个组件可以完成所需的工作,则可能可以在进程中加载​​此DLL并生成所需的东西.我建议你可以检查一下 文章 枚举了有关打印机驱动程序的许多详细信息.

Based on your description, I think we should ensure which printer model/printer driver you want to use. So the first we think what one should do is to examine how this driver is implemented. If you found out which component do your job which you need, you may be probably able to load this DLL in your process and produce something which you need. I suggest you can check this article which enumerates many detailed information about printer driver.

此外,还有许多方法可以让您的用户进行模拟.例如,您可以调用 LogonUser API 即可实现.请检查一下 文章 以获取更多详细信息.

In addition, there are many ways to let your user to do the impersonation. For example, you can invoke LogonUser API to achieve it. Please check this article for more detailed information.

关于记录事件日志以进行故障排除,我建议您可以创建一个Windows Service项目并使用

Regarding logging the event log to troubleshooting, I suggest you can create a Windows Service project and use EventLog class to achieve it.

希望此帮助.如有任何疑问,请随时告诉我们.

最好的问候,


这篇关于如何检测何时需要打印机驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆