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
It's better if you check which platform your script is running (using sys.platform
) and do a test based on that, e.g. import some hasAdminRights function from another, platform-specific module.
On Windows you could check whether Windows\System32
is writable using os.access
, but remember to try to retrieve system's actual "Windows" folder path, probably using pywin32. Don't hardcode one.