Advertisement
kshadow22

Check If Invoked As Admin

Nov 14th, 2019
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.58 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement