我有以下代码:
import os
print (os.listdir("C:/Windows/System32/config"))
print (os.listdir("C:/Windows/System32/winevt"))
我正在以管理员身份运行此Python脚本,并确认这些目录确实存在。
第一行输出了一些文件和文件夹,但不是所有文件。例如,其中包含一个名为“ SOFTWARE”的注册表配置单元,该配置单元不会出现在输出中。
第二行表示未识别路径。这是完整的输出:
['Journal', 'RegBack', 'systemprofile', 'TxR']
Traceback (most recent call last):
File "test.py", line 3, in <module>
print (os.listdir("C:/Windows/System32/winevt"))
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:/Windows/System32/winevt'
此模块(os.listdir
)在系统上的其他任何地方都可以正常工作,但不能在System32内工作。我怀疑这可能与权限有关,但是由于我已经以管理员身份运行脚本,因此不太确定如何解决该问题。
我们将不胜感激。谢谢!