Cross-platform way to check admin rights in a Python script under Windows?

前端 未结 5 1626
傲寒
傲寒 2021-02-01 18:57

Is there any cross-platform way to check that my Python script is executed with admin rights? Unfortunately, os.getuid() is UNIX-only and is not available under Win

5条回答
  •  死守一世寂寞
    2021-02-01 19:50

    Administrator group membership (Domain/Local/Enterprise) is one thing..

    tailoring your application to not use blanket privilege and setting fine grained rights is a better option especially if the app is being used iinteractively.

    testing for particular named privileges (se_shutdown se_restore etc), file rights is abetter bet and easier to diagnose.

提交回复
热议问题