1

How can I elevate my program on demand? (For example when clicking a button). I don't like to set the privileges in the manifests file, I am talking about elevating my VB.Net program at runtime. Does anyone know how to do this? I appreciate every helpful answer :)

Madara Uchiha
  • 119
  • 2
  • 11

2 Answers2

1

You can't elevate your program on demand as such. Your options are:

Community
  • 1
  • 1
Matt Wilko
  • 26,449
  • 10
  • 89
  • 138
0

Okay, using the RunAs-Method to elevate it. (This requires a restart tho)

    Private Sub RestartElevated()
  Dim startInfo As New ProcessStartInfo()
  startInfo.UseShellExecute = True
  startInfo.WorkingDirectory = Environment.CurrentDirectory
  startInfo.FileName = Application.ExecutablePath
  startInfo.Verb = "runas"
  Try
    Dim p As Process = Process.Start(startInfo)
  Catch ex As System.ComponentModel.Win32Exception
    Return
  End Try

  Application.[Exit]()
    End Sub
Madara Uchiha
  • 119
  • 2
  • 11