Created
July 7, 2016 15:21
-
-
Save WindfallLabs/334c96fd7128f6ca586615f31fd1631c to your computer and use it in GitHub Desktop.
get_users.py -- Searches Window's /Users/ file for write-accessable user folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
get_users.py -- Searches Window's /Users/ file for write-accessable user folders | |
and returns a list of write-accessible folder names (i.e. likely user name). | |
""" | |
import os | |
def get_users(): | |
users_dir = r"C:\Users" | |
ignore = {"All Users", "Default", "Public"} | |
users = set() | |
for path in os.listdir(users_dir): | |
try: | |
os.listdir(os.path.join(users_dir, path)) | |
users.add(path) | |
except WindowsError: | |
pass | |
return list(users.difference(ignore)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment