Search code examples
pythonwindowsadministrator

Determine if current user is in Administrators group (Windows/Python)


I want certain functions in my application to only be accessible if the current user is an administrator.

How can I determine if the current user is in the local Administrators group using Python on Windows?


Solution

  • You could try this:

    import ctypes
    print ctypes.windll.shell32.IsUserAnAdmin()