Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have programmed a Windows Service that open a document in Microsoft Word, and then print it to a Ghostscript PDF printer to create a PDF file.

It works perfectly on Windows 2003 server. But running it on Windows 2008 r2 fails. I am aware of the Desktop folders that need to be created under the system profile, and that solved another problem I had at first.

If I run the service as an application instead, everything works perfect. So it seems that everything is setup and configured correctly.

But when I run it as a Service, I get the following error in my logfile, generated from Microsoft Word:

Error in Microsoft Word: Word cannot print. There is no printer installed.

I have added a printer and manually selected the Ghostscript driver, and also set it as a default printer. So it should work.

When I added the printer I was logged in as an administrator. And it is the same user that runs the Service (it is not the system user). However I have read somewhere that the services still uses the internal users environment in 2008, so maybe that is the problem.

share|improve this question

migrated from stackoverflow.com Jan 15 '13 at 8:42

This question came from our site for professional and enthusiast programmers.

2  
Everyone posting questions here is seeking answers as quickly as possible. –  Damien_The_Unbeliever Jan 15 '13 at 7:47
add comment

1 Answer

You wont believe this. I finally got it to work.

Everytime I ran my Service the printer job got stuck in the queue with status "spooling...". I discovered that the following code segment somehow upheld the printing job.

while (WordApp.BackgroundPrintingStatus > 0) { sleeeeeeeeep for 250 milliseconds }

Removing this solved the problem!! The printerjob never get stuck, and runs smothly.

Unbelievable..

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.