Read Standard Output of a Child Process by CreateProcessAsUser

  • Thread starter Thread starter Bo
  • Start date Start date
B

Bo

In my asp.net webservice application, I need to launch a DOS process
as authorized users. To impersonate users, I use <impersonation =
true> in my webconfig. I can't use Diagnostics.Process.Start, because
it creates a child process using parent process token "System", not
the impersonated thread token. I don't want to use
CreateProcessWithLogonW, because my application impersonates different
users and it is not a good idea to handle passwords. So I am using
CreateProcessAsUser to handle it. Since I can't find any C# examples
with CreateProcessAsUser, I spent hours to figure it out.

Now CreateProcessAsUser is working for me, I don't know how to read
standard output and error from the child process. There is a help page
"Creating a Child Process with Redirected Input and Output" for C++.
Since I don't know much about C++, can someone create a C# sample code
from it?

Once I have a working sample that can create child process as
impersonated user and redirect standard output and error, I will post
it in the newsgroups. Many people can benefit from it.
 
Hi,

Based on that C++ article, I think you should P/invoke these APIs to get
this done.
Can you show me your where is your difficulty of tranlating this code?
I think the thing you shoud be careful of is the Marshal.
For more information about P/invoke, please refer to the article below:
http://msdn.microsoft.com/msdnmag/issues/03/07/NET/

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Bo,

Is your problem resolved?
If there is still anything unclear, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top