2

When I use Win32 API CreateProcessAsUser() to execute a program with impersonated user in my C# .NET project, it was successful.

But I want implement that using .NET Framework API.

There is a similar method like System.Diagnostics.Process.Start() But it's not exactly same as CreateProcessAsUser().

The function CreateProcessAsUser() receives "hToken" at the first parameter. So when I duplicate a token and use it to that function, I can impersonate a user and execute a program with that user.

But the method System.Diagnostics.Process.Start() doesn't provide such a parameter.

If there is anyone who knows this, would you please let me know? Thanks

llawlight
  • 21
  • 2

2 Answers2

2

ProcessStartInfo has UserName and Password properties in NET 2.0 or greater.

user12864
  • 581
  • 4
  • 7
  • I want to execute a program using a process token of another process. And I already used that override you said, but it was failed because of permission deny. – llawlight Jun 26 '15 at 04:41
1

There is no native solution. I'm sorry I disappointed you.

As Microsoft's Knowledge Base advises, You can do it only through P/Invocation (exactly like you do): https://support.microsoft.com/en-us/kb/889251

Vizor
  • 396
  • 3
  • 14