Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Ask if you want to elevate the permissions of your program or not

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
or simply
Code
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

in appmanifest because if you have to ask for permission then that probably means you're doing something that requires it - hence you don't need to run the application at all if they can't do it.
The first part already made me lose faith...
[Image: IQE6i8G.png]

BlackCap Wrote:You're even more verbose than Java.
About using GoTo's in VB/C#:
Only3 Wrote:asm use it why u shouldnt
(Apr 3, 2014 11:28 AM)Dispersia Wrote:  or simply
Code
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

in appmanifest because if you have to ask for permission then that probably means you're doing something that requires it - hence you don't need to run the application at all if they can't do it.

Thats also a way to do it, but this asks if you want to elevate the permissions.

Code
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Requires you to ONLY run it as admin.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by Emre_Sep 2, 2019 03:48 AM 0 159 Sep 2, 2019 03:48 AM
Last Post: Emre_
[Shell] by Emre_Aug 31, 2019 03:04 PM 0 76 Aug 31, 2019 03:04 PM
Last Post: Emre_
[Shell] by gogglebotMay 26, 2018 08:48 PM 30 1,725 May 26, 2018 08:48 PM
Last Post: Erhan