我想通过将文本文件移动到$Extend
目录来隐藏它(这个目录是什么?)。所以我cmd
以管理员身份运行 并运行以下代码:
C:\Windows\system32>copy I:\ToHide.txt I:\$Extend
Access is denied.
0 file(s) copied.
C:\Windows\system32>
如您所见,我不能,我收到拒绝访问错误。所以我尝试获取目标目录($Extend
)并将其更改ACLs
如下:
C:\Windows\system32>takeown /f I:\$Extend
SUCCESS: The file (or folder): "I:\$Extend" now owned by user "Abraham-VAIO\Abra
ham".
C:\Windows\system32>cacls I:\$Extend /G Abraham:F
Are you sure (Y/N)?Y
The system cannot find the file specified.
C:\Windows\system32>
Q1:为什么 cacls 看不到这个目录,而 takeown 可以!?
之后,我使用下面的 python 代码:
import win32api
import win32con
import win32security
FILENAME = "I:\\$Extend"
open (FILENAME, "w").close ()
print "I am", win32api.GetUserNameEx (win32con.NameSamCompatible)
sd = win32security.GetFileSecurity (FILENAME, win32security.OWNER_SECURITY_INFORMATION)
owner_sid = sd.GetSecurityDescriptorOwner ()
name, domain, type = win32security.LookupAccountSid (None, owner_sid)
print "File owned by %s\\%s" % (domain, name)
我再次收到拒绝访问:
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "C:\Users\Abraham\Desktop\teste.py", line 6, in <module>
open (FILENAME, "w").close ()
IOError: [Errno 13] Permission denied: 'I:\\$Extend'
>>>
Q2:这个python代码是等于takeown
还是替代cacls
?
Q3:为什么我在以管理员身份运行空闲(以及在命令行中的那个 python 之后)时收到拒绝访问?
最后的问题:
Q4: 为什么我用Windows Explorer 打不开这个目录,而用WinRAR 可以打开?Windows 是否限制了资源管理器的某些 API,但它们可用于其他软件?
顺便说一句,有什么方法可以使用 Python 或 C++ 或 ... 实现我的目标?(在 $Extend 目录中隐藏一些东西)