Codessentials

  • Increase font size
  • Default font size
  • Decrease font size
Home Coding tips .Net Check if running as Administrator

Check if running as Administrator

Sometimes you need to check if your application is started with administrator rights in order to perform some restricted tasks.

You can check this as follows:

 

Imports System.Security.Principal

Module Security
    Public Function IsAdmin() As Boolean
        Dim id As WindowsIdentity = WindowsIdentity.GetCurrent()
        Dim p As WindowsPrincipal = New WindowsPrincipal(id)
        Return p.IsInRole(WindowsBuiltInRole.Administrator)
    End Function
End Module
 

Bookmark

AddThis Social Bookmark Button

Related Articles


Newsflash

Yadis! Backup 1.9.8 is released!

See the new features right here!

Download this version here!