0

I would like to capture printer job request, check what is the source document and reject the print request if it's coming from a browser (chrome, IE, Firefox).
I tried using Windows Spooler API, FindFirstPrinterChangeNotification and FindNextPrinterChangeNotification function, but I notice the event raised by these API are asynchronous. By the time I handle the event the request, it reaches the printer. Is there a way I can capture the print Jobs and allow it to reach the printer only if it meets a certain criterion (non-browser print request in my case).

Any help would be appreciated.

P.S. I would like to avoid developing and using a new Virtual Printer.

Jude Aloysius
  • 131
  • 1
  • 14
  • Who is actively trying to circumvent this control? Bear in mind that a skilled user can, in theory, write a simple winforms application in a text file in notepad that includes the webbrowser control, then compile it using just the command-line .NET compilers and produce for themselves a brand new browser application that your system knows nothing of. – Damien_The_Unbeliever May 29 '18 at 14:45
  • Have you tried nuget package `EventHook`? [Here](https://github.com/justcoding121/Windows-User-Action-Hook) you can find more details. – Sandeep May 29 '18 at 15:06
  • @Damien_The_Unbeliever you make it complicated. Much easier to open Excel. Drag webbrowser activex. Create a macro to call `webbrowser1.Navigate("www.google.com")`. I learned that by a couple of my users that actually bypass the policy that was blocking all browsers process to even start by using this method. Quite crafty for people that only know how to use Word and Excel. – Franck May 29 '18 at 15:11
  • Thanks @sandeep,i'll give it a try. I understand, there are many ways to by pass the system but in my case User are restricted to using Chrome and Firefox only. – Jude Aloysius May 30 '18 at 06:44
  • Are you able to enforce the printer (Properties->Advanced tab) setting "Start printing after last page is spooled"? Otherwise you may well miss the job. Still, much better if you can prevent printing at the app level, e.g. Sandeep's suggestion. – Nick Westgate May 30 '18 at 23:09
  • @sandeep, I tried EventHook, but this too, gives an asynchronous event. I am not able to block the print job. – Jude Aloysius May 31 '18 at 09:57

0 Answers0