如何编写Windows 10脚本以每次打印作业打印时逐一增加计数器?
我想在每次打印作业完成时,为Windows 10编写一个脚本以在.txt中添加1个。理想情况下,每天都有一个单独的计数,因此我可以看到一天内完成了多少个印刷作业。
感谢您了解如何进行此操作的任何帮助!
I'd like to write a script for Windows 10 to add 1 to a count in a .txt each time a print job completes. Ideally a separate count for each day, so I can see how many print jobs were completed in a day.
Any help in understanding how to go about this is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
打印服务已经在每次打印时都登录 - 您只需要启用适当的事件日志频道并消耗结果日志事件:
现在,启用了日志频道,打印服务将在每次执行一个事件ID 307的情况下记录事件ID 307本地打印工作。由于日志事件都有时间戳,因此每天获得计数就像使用
group-object
cmdlet:The print service already logs every time it prints - you just need to enable the appropriate event log channel and consume the resulting log events:
Now that the log channel is enabled, the print service will log an event with event ID 307 everytime it executes a local print job. Since the log events all have timestamps, getting a count per day is as simple as using the
Group-Object
cmdlet:可能有用的一种技术是查询类似的剥离器服务的统计信息:
这给出了这样的输出:
每次
打印spooler
服务重新启动时,统计数在您的最终脚本中考虑到这一点,这可能使此选项比Mathias的事件日志解决方案更棘手。One technique that might be useful is to query stats for the spooler service like this:
This gives output like this:
The stats are reset each time the
Print Spooler
service restarts, so you'll need to take that into account in your final script, which might make this a trickier option than Mathias' event log solution.