3

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

vivi11130704
  • 431
  • 8
  • 21

1 Answers1

1

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.

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219