Launching unmanaged code as another user

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg Wilson

    #1

    Launching unmanaged code as another user

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

    I do (VB.NET pseudo code)
    Dim moImpersonation Context As WindowsImperson ationContext
    = WindowsIdentity Iwant.impersona te()
    Shell('cmd /C TheCommandToLau nchTheUnmanaged Code')

    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?
  • Tian Min Huang

    #2
    RE: Launching unmanaged code as another user

    Hello Greg,

    Thanks for your post. I suggest that you can use P/Invoke to call
    CreateProcessAs User 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/cpconconsumingu nmanageddllfunc tions.asp?frame =true

    CreateProcessAs User
    http://msdn.microsoft.com/library/de...us/dllproc/bas
    e/createprocessas user.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.

    Comment

    Working...