none
Standard output from CreateProcessAsUser Always Empty in C# RRS feed

  • Question

  • I have a problem with StandardOutput of a process created with

    CreateProcessAsUser

    The standard output always is empty.

    I have the same question in

    https://stackoverflow.com/questions/51073835/standard-output-from-createprocessasuser-always-empty-in-c-sharp

    If you need more information tell me please,

    Thanks!

    Thursday, June 28, 2018 2:34 AM

All replies

  • Hi Juan,

    For your codes, It make me confused that in your Launch method, you get the token from the specific process “explorer” but use the token to launch another process (LaunchProcessAsUser) and use it to process the command line. Why don’t you process the command line directly? Can you tell us the logic of your codes?

    Regards,

    Dolen


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 29, 2018 9:06 AM
  • Sorry, I'll do that because I want to take a screenshot from windows services, so I need the context of the explorer, because from windows services It cannot access to user desktop,
    I do not know if this is understood
    Friday, June 29, 2018 3:13 PM
  • Sorry, I'll do that because I want to take a screenshot from windows services, so I need the context of the explorer, because from windows services It cannot access to user desktop,
    I do not know if this is understood

    If the Windows Service is running under the LocalSystem account then it can usually use WTSGetActiveConsoleSessionId to retrieve the session identifier of the user that is at the keyboard (versus an RDP session).

    The service can then call WTSQueryUserToken to obtain a token that can be used with CreateProcessAsUser to start an application in the user's session to take the screenshot.

    Since the service creates the pipes you will need to add the user to the pipes security descriptor
    • Edited by RLWA32 Friday, June 29, 2018 3:57 PM
    Friday, June 29, 2018 3:53 PM
  • The example That I Write Works, But It just cannot get data from standard output, So you say with your recommendation could I get the standard output in that way?

    Thanks

    Friday, June 29, 2018 4:38 PM
  • What I am saying is that it is likely that the default security descriptor on the end of the pipe passed to the user session process probably does not allow access to the pipe.  So the service should explicitly adjust the security descriptor so that the account under which the user session process runs will have access.

    Friday, June 29, 2018 4:52 PM