Python - checking if a user has administrator privileges

前端 未结 4 763
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 04:41

I\'m writing a little program as a self-learning project in Python 3.x. My idea is for the program to allow two fields of text entry to the user, and then plug the user\'s i

4条回答
  •  囚心锁ツ
    2021-01-01 05:09

    With pywin32, something like the following should work...:

    import pythoncom
    import pywintypes
    import win32api
    from win32com.shell import shell
    
    if shell.IsUserAnAdmin():
       ...
    

    And yes, it seems pywin32 does support Python 3.

提交回复
热议问题