Printing from a Windows Service

There are some problems printing from a Windows service which I will cover in this article as well as working through a solution. The main problem you will encounter printing from a service is that services usually run under the localsystem account which only has access to resources on the local system. As this account is separate from the account you login under it is also unaware of any network printer connections you have setup.

The simplest solution to this problem is to install your printers locally rather than connecting to a network resource, locally installed printers have the advantage of being visible to every user on your system including system accounts such as localsystem. To install a printer locally rather than connecting to a network printer start the "Add Printer Wizard" and select "Local printer attached to this computer" :

Add Printer

You can then step through the rest of the wizard specifying the printer driver, port and printer name.

The only insignificant downside to taking this approach is that print jobs will not get spooled to your normal file and print server making it slightly harder to manage the printing. The advantages over the alternative of running the service under an account which has access rights to a file and print server are significant, in particular the service can continue to spool print jobs even when the network is down, printing them out when it is restored.

All modern print servers are happy to accept print jobs from multiple sources so you shouldn't encounter any problems there.