Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 418947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:43:44+00:00 2026-05-12T18:43:44+00:00

I am writing a script to email the owner of a file when a

  • 0

I am writing a script to email the owner of a file when a separate process has finished. I have tried:

import os
FileInfo = os.stat("test.txt")
print (FileInfo.st_uid)

The output of this is the owner ID number. What I need is the Windows user name.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:43:45+00:00Added an answer on May 12, 2026 at 6:43 pm

    Once I stopped searching for file meta data and started looking for file security I found exactly what I was looking for.

    import tempfile
    import win32api
    import win32con
    import win32security
    
    f = tempfile.NamedTemporaryFile ()
    FILENAME = f.name
    try:
      sd = win32security.GetFileSecurity (FILENAME,win32security.OWNER_SECURITY_INFORMATION)
      owner_sid = sd.GetSecurityDescriptorOwner ()
      name, domain, type = win32security.LookupAccountSid (None, owner_sid)
    
      print "I am", win32api.GetUserNameEx (win32con.NameSamCompatible)
      print "File owned by %s\\%s" % (domain, name)
    finally:
      f.close ()
    

    Mercilessly ganked from http://timgolden.me.uk/python-on-windows/programming-areas/security/ownership.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple script written to process received email. Here are the tested
I'm writing a little script that allows me to import my Facebook contacts' email
I am writing a script which counts all files and folders recursively. I tried
I'm writing a script to backup a database. I have the following line: mysqldump
I'm writing a Python script to process emails returned from Procmail . As suggested
I am writing a Bash shell script for Mac that sends an email notification
Possible Duplicate: regexp to partly hide email? I'm currently writing a script that hides
I am writing a PHP script that will send via a cron an email
Just finished writing my app with google app script. embeded it on https://sites.google.com/site/1000eventz/home but
I have written a python script (mail.py) to send email in python, and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.