Run exe as impersonated account from


I am trying to run an exe from another account which has admin rights, I have this so far but its giving me an unknown error (0xfffffffe):

Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Int32) As Boolean
End Function
Public Sub RunAsAdmin()
    Dim tokenHandle As New IntPtr(0)
    If LogonUser(_ImpersinateUser, _ImpersinateDomain, _ImpersinatePassword, 2, 0, tokenHandle) Then

        Dim newId As New WindowsIdentity(tokenHandle)
        Using impersonatedUser As WindowsImpersonationContext = newId.Impersonate()

            Dim p As New Process
            p.StartInfo.FileName = "C:\\Temp\\MCPR.exe"
            p.StartInfo.WindowStyle = ProcessWindowStyle.Normal
            ShowWindow(p.MainWindowHandle, SW_RESTORE)

        End Using
    End If
End Sub
asked on Stack Overflow Feb 24, 2016 by Sam Lucas • edited Feb 25, 2016 by Sam Lucas

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0