Problem with Windows Service and network printers

9,690

Solution 1

I have solved the problem by requesting a network authentication to the server first and then installing the printer.

Thank you guys for your help.

Solution 2

You can log on to the computer as your service user accounts and add/configure/test network printers manually.

Solution 3

Why not set all printers up with a local queue, that way they're always local printers and you don't have the issue?

You can point a local queue to a network printer by creating a local port with the relevant IP address of the printer. (Go through the Add Printer wizard, Add a Local Printer (don't let it search plug and play), Create a New Port, Use Standard TCP/IP port.

Share:
9,690

Related videos on Youtube

mrtaikandi
Author by

mrtaikandi

Updated on September 17, 2022

Comments

  • mrtaikandi
    mrtaikandi almost 2 years

    I have a Windows Service application that every now and then should print some documents. As far as I know, to print those documents, my service must be run with a user account other than Local Service or Network Service. So i have created a user account and added that to the Administrators group and ran the service with it.

    With locally installed printers, I don't have any problems because those printers are automatically installed for all accounts. To be able to print with the network printers, I have created another application that syncs the installed printers of the currently logged in user with the user account that my service uses with the rundll32.exe printui.dll,PrintUIEntry command.

    In Vista and Windows7 I don't have any problems with the syncing of the printers because every time that a printer should be installed the authentication window will open and it asks for the appropriate user account to install that printer (The service user account is not created on the network printers computers) but in XP a find dialog with the "Connecting to {printername}" caption will appear and stops responding, or sometimes it installs the printer but every time service tries to print, a Win32Exception with "A StartDocPrinter call was not issued" message will throw and in the user account that runs the sync application a duplicate printer will be shown and I couldn't delete those printers unless with force (using registry).

    Am I doing the right thing for printing documents with Windows Services at all? If yes, how can I solve the above-mentioned problem? And if not, what the heck should I do?

    Thanks.

  • mrtaikandi
    mrtaikandi almost 15 years
    There is nothing wrong the user account. I have tested it the way you mentioned. But I don't want to log in to the account every time a printer installed or removed. This is why i have developed the sync application.
  • John Gardeniers
    John Gardeniers over 14 years
    How often do you install or remove printers that will be used for this service? Massimo's answer is the way I have always done it because it's fool proof.
  • Tony Edgecombe
    Tony Edgecombe over 14 years
    This is probably the most robust solution as the print jobs can queue locally if there is a network problem.