Windows 2008 service Office automation cant find printer.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Windows 2008 service Office automation cant find printer.

  1. #1
    Join Date
    Jan 2013
    Posts
    5

    Windows 2008 service Office automation cant find printer.

    Hi,

    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 work perfectly on Windows 2003 server. But running it on Windows 2008 r2 it 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).

    Please help me with this! It is very urgent. I have spent a couple of days now googling on it but cant find anything useful.

    Kind regards
    Marcus

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,451

    Re: Windows 2008 service Office automation cant find printer.

    Possibly, "Allow service to interact with desktop"?

  3. #3
    Join Date
    Jan 2013
    Posts
    5

    Re: Windows 2008 service Office automation cant find printer.

    Quote Originally Posted by sotoasty View Post
    Possibly, "Allow service to interact with desktop"?
    Thanks, but as I said the service is configured to run with a specific user, not the internal one (so this checkbox is unavaliable).

    But I recently discovered in some other forums that even if the Service is run by a specific user, it apparently get the environment
    from the interal user. Maybe thats why it cant locate the printer.

    Do anyone know how to fix this? To make the system user able to find the printers?

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,358

    Re: Windows 2008 service Office automation cant find printer.

    Quote Originally Posted by df03anma View Post
    Do anyone know how to fix this? To make the system user able to find the printers?
    Is that printer available to the user? Can you log on under that user account and check?

  5. #5
    Join Date
    Jan 2013
    Posts
    5

    Re: Windows 2008 service Office automation cant find printer.

    Quote Originally Posted by Arjay View Post
    Is that printer available to the user? Can you log on under that user account and check?
    How do you log in as the internal user? I dont think it is possible..

  6. #6
    Join Date
    Jan 2013
    Posts
    5

    Re: Windows 2008 service Office automation cant find printer.

    I have to make a correction.

    I tried this in two similar windows 2008 server environments (vmware), and I realize that in one of them I forgot to configure the service to run with the .\administrator. Instead it runs with the "local service" account, which might explain why I cant find any printer installed.

    But, when I change it to administrator, i still get problem. Error 372 in the event viewer, a classic spooling problem. In advanced setup on the printer i changed the setting to print directly to the printer (without spooling), but it did not work (the error in event viewer dissapeared though).

    Please help me with this one.

  7. #7
    Join Date
    Jan 2013
    Posts
    5

    Re: Windows 2008 service Office automation cant find printer.

    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..

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,358

    Re: Windows 2008 service Office automation cant find printer.

    Quote Originally Posted by df03anma View Post
    How do you log in as the internal user? I dont think it is possible..
    What do you mean by internal user? Do you mean the built-in service account?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center