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

Launching unmanaged code as another user

P: n/a
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?
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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/de...us/cpguide/htm
l/cpconconsumingunmanageddllfunctions.asp?frame=true

CreateProcessAsUser
http://msdn.microsoft.com/library/de...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.

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.