Run with Administrator Credentials

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

Is there a way to invoke an external program in C# with Administrator
credentials? You know run an external VBS or batch?

Any reference material would be useful.

TIA
 
JM said:
Hi

Is there a way to invoke an external program in C# with Administrator
credentials? You know run an external VBS or batch?

Any reference material would be useful.

TIA

Yes, there is, you have to call Win32's CreateProcessWithLogonW using
PInvoke., or wait for v2.0 of the framework.
Note that this won't work when called from a service.

Willy.
 
Check out WindowsIdentity class in System.Security.Principal.

There is an Impersonate() method that will do what you are trying to
accomplish. The missing link with this class is that you have to obtain an
access token handle to use it. The only way I know of doing this is by
pinvoking one of the Win32 security functions like LogonUser().

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
 
Ken Varn said:
Check out WindowsIdentity class in System.Security.Principal.

There is an Impersonate() method that will do what you are trying to
accomplish. The missing link with this class is that you have to obtain
an
access token handle to use it. The only way I know of doing this is by
pinvoking one of the Win32 security functions like LogonUser().

--


Ken,

No it won't. OP's needs to spawn another process that must run as
administrator.
When creating a process from an impersonating thread, the process will use
the callers PROCESS identity, not the impersonating thread's identity.

Willy.
 
Back
Top