Beispiel für die Registry, wie ich mir das vorstelle (http://fstaal01.home.xs4all.nl/swreg-us.html):
Code: Alles auswählen
SWREG ACL "KEY" /GE:F
Gary
Code: Alles auswählen
SWREG ACL "KEY" /GE:F
Code: Alles auswählen
import os, stat
Adware = [
"C:\\Users\\Machiavelli\\Babylon",
"C:\\ProgramData\\Babylon",
"C:\\Babylon"
]
for bad in Adware:
if os.path.isdir(bad):
os.chmod(bad, stat.S_IWUSR)
try:
os.removedirs(bad)
print bad + " was removed succesfully."
except WindowsError:
print bad + " wasn't succesfully removed. ['WINDOWSERROR']"
Demnach wird also die von dir angeforderte Operation ignoriert.Note: Although Windows supports chmod(), you can only set the file’s read-only flag with it (via the stat.S_IWRITE and stat.S_IREAD constants or a corresponding integer value). All other bits are ignored.
Ganz einfach, weil ein Administrator nur beschränkte Rechte hat. Ich hatte man alle Rechte auf ein Verzeichnis gelöscht und somit konnte auch der Administrator diese Rechte nicht wieder setzen.anogayales hat geschrieben:Was spricht dagegen das Skirpt mit Administratorrechten zu starten?
Code: Alles auswählen
import win32security
import ntsecuritycon as con
FILENAME = "whatever"
userx, domain, type = win32security.LookupAccountName ("", "User X")
usery, domain, type = win32security.LookupAccountName ("", "User Y")
sd = win32security.GetFileSecurity(FILENAME, win32security.DACL_SECURITY_INFORMATION)
dacl = sd.GetSecurityDescriptorDacl() # instead of dacl = win32security.ACL()
dacl.AddAccessAllowedAce(win32security.ACL_REVISION, con.FILE_GENERIC_READ | con.FILE_GENERIC_WRITE, userx)
dacl.AddAccessAllowedAce(win32security.ACL_REVISION, con.FILE_ALL_ACCESS, usery)
sd.SetSecurityDescriptorDacl(1, dacl, 0) # may not be necessary
win32security.SetFileSecurity(FILENAME, win32security.DACL_SECURITY_INFORMATION, sd)