Apr 3, 2014 11:26 AM
(This post was last modified: Apr 3, 2014 11:29 AM by E3zh00rn.)
This will check if your program is run as administrator, if not it will ask you to elevate the permissions or not.
Code
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Not My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) Then
Dim YesNo
YesNo = MsgBox("You have run the program without administrator rights, would you like to elevate permissions?", MsgBoxStyle.YesNo)
If YesNo = vbNo Then
Me.Show()
Else
Dim pInf As New ProcessStartInfo
With pInf
.FileName = Application.ExecutablePath
.UseShellExecute = True
.Verb = "runas"
.WindowStyle = ProcessWindowStyle.Normal
End With
Dim p As New Process
p = Process.Start(pInf)
End
End If
End If
End Sub


![[Image: IQE6i8G.png]](https://i.imgur.com/IQE6i8G.png)