By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,218 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,218 IT Pros & Developers. It's quick & easy.

Read Standard Output of a Child Process by CreateProcessAsUser

P: n/a
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.
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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.

Nov 15 '05 #2

P: n/a

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.

Nov 15 '05 #3

P: n/a
Bo
Jeff,

I avoided the problem by saving batch output into files.

Thanks,

Bo
Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.