I'm using windows machine and python 3. I'm trying to get the user id from windows files:
import os
os.stat('filepath').st_uid
However this only returns st_uid = 0 which doesn't make sense.
Can someone please help? If I can't use st_uid, what else I can use to obtain the file user info?
Thanks!
Update: Thanks for the help guys. I end up using windows security API to obtain user information:
Here is the link
os.stat() on windows seems very limited: os.stat() on Windows
so id values are zeroed: you cannot use that to get the user id info.
But this Q & A gives most methods to do it in python: Howto determine file owner on windows using python without pywin32
Note: this is a CW answer, as the question isn't really a duplicate of either of the linked answers, but this answer just links both aspects: the issue and the workarounds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With