How to install printer which should be accessible from windows service?












1















My application started as a windows service which does not see printer installed on my PC.

But if this application is started as a regular windows application it can see this printer.

How can I install this printer, which should be accessible from windows service?



I need to send pdf files to this printer from a windows service. But windows service does not see my printer.

Windows service uses a Win API function EnumPrinters to get the list of printers.

Also, Win API function GetDefaultPrinter does not return default printer if this function is called from a windows service.



OS - Windows 7.

Printer - HP LaserJet P2055.

It is installed as network printer on a remote computer.

I install it on my PC using following steps:

1. Open Device and Printers.

2. Add a printer.

3. Add a network printer.

4. Find printer in the directory, based on location or feature.










share|improve this question

























  • This question is vague and lacks specific details for someone to be able to answer. Please provide more details on what version of Windows, brand & model of printer, what exactly you are try to accomplish and what you you've researched, etc. Details are very helpful.

    – CharlieRB
    Apr 4 '14 at 11:17











  • @CharlieRB Added some details.

    – Volodymyr Bezuglyy
    Apr 4 '14 at 11:40
















1















My application started as a windows service which does not see printer installed on my PC.

But if this application is started as a regular windows application it can see this printer.

How can I install this printer, which should be accessible from windows service?



I need to send pdf files to this printer from a windows service. But windows service does not see my printer.

Windows service uses a Win API function EnumPrinters to get the list of printers.

Also, Win API function GetDefaultPrinter does not return default printer if this function is called from a windows service.



OS - Windows 7.

Printer - HP LaserJet P2055.

It is installed as network printer on a remote computer.

I install it on my PC using following steps:

1. Open Device and Printers.

2. Add a printer.

3. Add a network printer.

4. Find printer in the directory, based on location or feature.










share|improve this question

























  • This question is vague and lacks specific details for someone to be able to answer. Please provide more details on what version of Windows, brand & model of printer, what exactly you are try to accomplish and what you you've researched, etc. Details are very helpful.

    – CharlieRB
    Apr 4 '14 at 11:17











  • @CharlieRB Added some details.

    – Volodymyr Bezuglyy
    Apr 4 '14 at 11:40














1












1








1








My application started as a windows service which does not see printer installed on my PC.

But if this application is started as a regular windows application it can see this printer.

How can I install this printer, which should be accessible from windows service?



I need to send pdf files to this printer from a windows service. But windows service does not see my printer.

Windows service uses a Win API function EnumPrinters to get the list of printers.

Also, Win API function GetDefaultPrinter does not return default printer if this function is called from a windows service.



OS - Windows 7.

Printer - HP LaserJet P2055.

It is installed as network printer on a remote computer.

I install it on my PC using following steps:

1. Open Device and Printers.

2. Add a printer.

3. Add a network printer.

4. Find printer in the directory, based on location or feature.










share|improve this question
















My application started as a windows service which does not see printer installed on my PC.

But if this application is started as a regular windows application it can see this printer.

How can I install this printer, which should be accessible from windows service?



I need to send pdf files to this printer from a windows service. But windows service does not see my printer.

Windows service uses a Win API function EnumPrinters to get the list of printers.

Also, Win API function GetDefaultPrinter does not return default printer if this function is called from a windows service.



OS - Windows 7.

Printer - HP LaserJet P2055.

It is installed as network printer on a remote computer.

I install it on my PC using following steps:

1. Open Device and Printers.

2. Add a printer.

3. Add a network printer.

4. Find printer in the directory, based on location or feature.







printer services windows-services






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 4 '14 at 14:28









Mr. Hargrove

727514




727514










asked Apr 4 '14 at 10:06









Volodymyr BezuglyyVolodymyr Bezuglyy

11315




11315













  • This question is vague and lacks specific details for someone to be able to answer. Please provide more details on what version of Windows, brand & model of printer, what exactly you are try to accomplish and what you you've researched, etc. Details are very helpful.

    – CharlieRB
    Apr 4 '14 at 11:17











  • @CharlieRB Added some details.

    – Volodymyr Bezuglyy
    Apr 4 '14 at 11:40



















  • This question is vague and lacks specific details for someone to be able to answer. Please provide more details on what version of Windows, brand & model of printer, what exactly you are try to accomplish and what you you've researched, etc. Details are very helpful.

    – CharlieRB
    Apr 4 '14 at 11:17











  • @CharlieRB Added some details.

    – Volodymyr Bezuglyy
    Apr 4 '14 at 11:40

















This question is vague and lacks specific details for someone to be able to answer. Please provide more details on what version of Windows, brand & model of printer, what exactly you are try to accomplish and what you you've researched, etc. Details are very helpful.

– CharlieRB
Apr 4 '14 at 11:17





This question is vague and lacks specific details for someone to be able to answer. Please provide more details on what version of Windows, brand & model of printer, what exactly you are try to accomplish and what you you've researched, etc. Details are very helpful.

– CharlieRB
Apr 4 '14 at 11:17













@CharlieRB Added some details.

– Volodymyr Bezuglyy
Apr 4 '14 at 11:40





@CharlieRB Added some details.

– Volodymyr Bezuglyy
Apr 4 '14 at 11:40










1 Answer
1






active

oldest

votes


















0














You're probably running the service in different user context than when run interactively (as a 'normal app'). Try to run it in the context of a user who has a printer installed:




A Windows service that is designed to print can use the Win32 GDI APIs to print documents to a printer. There are some considerations when printing from Windows services, however. If all the print jobs can be sent with one user's credentials, the service can be run under that user's account and will have access to the printers that are known to that user on that computer. If the service must print using the credentials of one or more users defined at run time, then the service must call LogonUser(), LoadUserProfile(), and ImpersonateLoggedOnUser() before printing.




(quoted from: http://blogs.msdn.com/b/dsui_team/archive/2013/06/24/printing-from-a-windows-service.aspx)



You may also want to install your printer computer wide (for all users) using printui.dll, eg,:
Add per machine printer connection:
rundll32 printui.dll PrintUIEntry /ga /n\client2printer2



(run rundll32 printui.dll,PrintUIEntry /? to see all options)






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f737627%2fhow-to-install-printer-which-should-be-accessible-from-windows-service%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You're probably running the service in different user context than when run interactively (as a 'normal app'). Try to run it in the context of a user who has a printer installed:




    A Windows service that is designed to print can use the Win32 GDI APIs to print documents to a printer. There are some considerations when printing from Windows services, however. If all the print jobs can be sent with one user's credentials, the service can be run under that user's account and will have access to the printers that are known to that user on that computer. If the service must print using the credentials of one or more users defined at run time, then the service must call LogonUser(), LoadUserProfile(), and ImpersonateLoggedOnUser() before printing.




    (quoted from: http://blogs.msdn.com/b/dsui_team/archive/2013/06/24/printing-from-a-windows-service.aspx)



    You may also want to install your printer computer wide (for all users) using printui.dll, eg,:
    Add per machine printer connection:
    rundll32 printui.dll PrintUIEntry /ga /n\client2printer2



    (run rundll32 printui.dll,PrintUIEntry /? to see all options)






    share|improve this answer




























      0














      You're probably running the service in different user context than when run interactively (as a 'normal app'). Try to run it in the context of a user who has a printer installed:




      A Windows service that is designed to print can use the Win32 GDI APIs to print documents to a printer. There are some considerations when printing from Windows services, however. If all the print jobs can be sent with one user's credentials, the service can be run under that user's account and will have access to the printers that are known to that user on that computer. If the service must print using the credentials of one or more users defined at run time, then the service must call LogonUser(), LoadUserProfile(), and ImpersonateLoggedOnUser() before printing.




      (quoted from: http://blogs.msdn.com/b/dsui_team/archive/2013/06/24/printing-from-a-windows-service.aspx)



      You may also want to install your printer computer wide (for all users) using printui.dll, eg,:
      Add per machine printer connection:
      rundll32 printui.dll PrintUIEntry /ga /n\client2printer2



      (run rundll32 printui.dll,PrintUIEntry /? to see all options)






      share|improve this answer


























        0












        0








        0







        You're probably running the service in different user context than when run interactively (as a 'normal app'). Try to run it in the context of a user who has a printer installed:




        A Windows service that is designed to print can use the Win32 GDI APIs to print documents to a printer. There are some considerations when printing from Windows services, however. If all the print jobs can be sent with one user's credentials, the service can be run under that user's account and will have access to the printers that are known to that user on that computer. If the service must print using the credentials of one or more users defined at run time, then the service must call LogonUser(), LoadUserProfile(), and ImpersonateLoggedOnUser() before printing.




        (quoted from: http://blogs.msdn.com/b/dsui_team/archive/2013/06/24/printing-from-a-windows-service.aspx)



        You may also want to install your printer computer wide (for all users) using printui.dll, eg,:
        Add per machine printer connection:
        rundll32 printui.dll PrintUIEntry /ga /n\client2printer2



        (run rundll32 printui.dll,PrintUIEntry /? to see all options)






        share|improve this answer













        You're probably running the service in different user context than when run interactively (as a 'normal app'). Try to run it in the context of a user who has a printer installed:




        A Windows service that is designed to print can use the Win32 GDI APIs to print documents to a printer. There are some considerations when printing from Windows services, however. If all the print jobs can be sent with one user's credentials, the service can be run under that user's account and will have access to the printers that are known to that user on that computer. If the service must print using the credentials of one or more users defined at run time, then the service must call LogonUser(), LoadUserProfile(), and ImpersonateLoggedOnUser() before printing.




        (quoted from: http://blogs.msdn.com/b/dsui_team/archive/2013/06/24/printing-from-a-windows-service.aspx)



        You may also want to install your printer computer wide (for all users) using printui.dll, eg,:
        Add per machine printer connection:
        rundll32 printui.dll PrintUIEntry /ga /n\client2printer2



        (run rundll32 printui.dll,PrintUIEntry /? to see all options)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 4 '14 at 14:35









        wmzwmz

        5,72211127




        5,72211127






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f737627%2fhow-to-install-printer-which-should-be-accessible-from-windows-service%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Probability when a professor distributes a quiz and homework assignment to a class of n students.

            Aardman Animations

            Are they similar matrix