Launching unmanaged code as another user

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?
 
T

Tian Min Huang

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top