locked
run service, that interacts with desktop, as admin RRS feed

  • Question

  • Hi,

     

    I have a service where the follogin check box is checked: "Allow service to interact with desktop".

    How can I assure that this service runs always as admin?

     

    Thursday, May 19, 2011 7:22 AM

Answers

  • ==> What must be done, that the LowLevelkeyboardProc is called in the service  without the interactive flag?

    You must split your service in two parts, and service part and an GUI part. Both parts use interprocess communication for communication (i.e. a memory mapped file, pipes, ...). The service part is able to run in the system context. The user part MUST run in the current user context. (This text is copied from my very first post)


    • Proposed as answer by SimonRev Thursday, May 19, 2011 2:12 PM
    • Marked as answer by Jesse Jiang Wednesday, June 1, 2011 3:23 AM
    Thursday, May 19, 2011 12:51 PM

All replies

  • With the release of Windows Vista interactive services are not supported anymore. The recommentadtion not using interactive services anymore exists since the release of Windows XP if I remember correctly.

    You must split your service in two parts, and service part and an GUI part. Both parts use interprocess communication for communication (i.e. a memory mapped file, pipes, ...). The service part is able to run in the system context. The user part MUST run in the current user context.

    Thursday, May 19, 2011 8:18 AM
  • The services loads a DLL with a LowLevelkeyboardProc and registers this proc. This proc is only called if the service is interactive. ==> Therefore the service must be interactive.

    Since this service runs without admin privileges, an unhandled exception "privileged instruction" is thrown after leaving the LowLevelkeyboardProc. ==> Therefore this service must always run as admin.

    As you see, in this case your hint "splitting up into two sevices", can not be applied.

            How can this conflict be solved?

     


    Thursday, May 19, 2011 8:35 AM
  • What OS are you using?

    Interactive Services are not supported anymore since Vista. That is a fact. Quotation from this linked MSDN site:

    Important  Services cannot directly interact with a user as of Windows Vista. Therefore, the techniques mentioned in the section titled Using an Interactive Service should not be used in new code.

    You do not have access to the user desktop with an interactive service anymore. That is also a fact. It may be possibel that the flag interactive will still be handled, but you definately do not have any access to the current user desktop.

    Thursday, May 19, 2011 8:58 AM
  • I use both: XP  & Win 7.

     

    Ok so I will remove the interactive flag.

    But then the LowLevelkeyboardProc is not called any more.

    ==> What must be done, that the LowLevelkeyboardProc is called in the service  without the interactive flag?

     

     

    Thursday, May 19, 2011 9:48 AM
  • ThePerfectWave wrote:

    ==> What must be done, that the LowLevelkeyboardProc is called in  the service without the interactive flag?

    No matter how many times you ask the same question, the answer will not  change. What you want cannot be done. You will have to reconsider your  design. Keyboard handling must be done in a regular user process, not in  a service.

    Thursday, May 19, 2011 12:35 PM
  • ==> What must be done, that the LowLevelkeyboardProc is called in the service  without the interactive flag?

    You must split your service in two parts, and service part and an GUI part. Both parts use interprocess communication for communication (i.e. a memory mapped file, pipes, ...). The service part is able to run in the system context. The user part MUST run in the current user context. (This text is copied from my very first post)


    • Proposed as answer by SimonRev Thursday, May 19, 2011 2:12 PM
    • Marked as answer by Jesse Jiang Wednesday, June 1, 2011 3:23 AM
    Thursday, May 19, 2011 12:51 PM
  • Hello,

     

    Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, May 24, 2011 3:16 AM