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.
 
Top