kshadow22

Check If Invoked As Admin

Nov 14th, 2019
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Security.Principal
  2.  
  3.  Dim identity = WindowsIdentity.GetCurrent()
  4.         Dim principal = New WindowsPrincipal(identity)
  5.         Dim isElevated As Boolean = principal.IsInRole(WindowsBuiltInRole.Administrator)
  6.         If isElevated Then
  7.             Me.Text = ("Navigation Main (Admin)")
  8.             Form1Name.Text = Me.Text
  9.             Admin_Enabled = True
  10.         Else
  11.             Admin_Enabled = False
  12.             Me.Text = ("Navigation Main (Standard)")
  13.             Form1Name.Text = Me.Text
  14.             Label73.Visible = True
  15.         End If
  16.  
  17. youtube.com/kshadow22
RAW Paste Data