Launching unmanaged code as another user

  • Thread starter Thread starter Greg Wilson
  • Start date Start date
G

Greg Wilson

I need to launch an app from inside my VB.NET app as a
specific user.

I do (VB.NET pseudo code)
Dim moImpersonationContext As WindowsImpersonationContext
= WindowsIdentityIwant.impersonate()
Shell('cmd /C TheCommandToLaunchTheUnmanagedCode')

I can verify that the Shell command runs under the new
Windows Identity, but the unmanaged code still launched
under the logged on user.

What am I doing wrong?
 
Hello Greg,

Thanks for your post. I suggest that you can use P/Invoke to call
CreateProcessAsUser directly to launch an app as a specific user. Please
refer to the following MSDN articles:

Consuming Unmanaged DLL Functions
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconconsumingunmanageddllfunctions.asp?frame=true

CreateProcessAsUser
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
e/createprocessasuser.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
 
Back
Top