kshadow22

Restart Application As Administrator

Nov 14th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub RestartElevated()
  2.     Dim startInfo As ProcessStartInfo = New ProcessStartInfo()
  3.     startInfo.UseShellExecute = True
  4.     startInfo.WorkingDirectory = Environment.CurrentDirectory
  5.     startInfo.FileName = Application.ExecutablePath
  6.     startInfo.Verb = "runas"
  7.     Try
  8.         Dim p As Process = Process.Start(startInfo)
  9.     Catch ex As Exception
  10.         Return 'If cancelled, do nothing
  11.    End Try
  12.     Application.Exit()
  13. End Sub
  14.  
  15. youtube.com/kshadow22
Add Comment
Please, Sign In to add comment