B4J Code Snippet Test if process is running as administrator on Windows

B4X:
Private Sub IsRunningAsAdmin As Boolean
    Try
        Dim f As String = GetEnvironmentVariable("SYSTEMDRIVE", "") & "\isadmin.txt"
        File.WriteString(f, "", "test")
        File.Delete(f, "")
        Return True
    Catch
        Return False
    End Try
End Sub

A bit hacky but should work. Windows only.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…