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
p.Start()
ShowWindow(p.MainWindowHandle, SW_RESTORE)
End Using
End If
End Sub
User contributions licensed under CC BY-SA 3.0