简体   繁体   English

如何在Python中通过WMI读取网络计算机文件

[英]how to read network computer files by wmi in python

I am using wmi module in python for network connection. 我在python中使用wmi模块进行网络连接。 I need to read all files which are present in network computer drives. 我需要读取网络计算机驱动器中存在的所有文件。 So give me suggestion how can i do by using wmi module. 所以给我建议,我该如何使用wmi模块。

I have done connection by below code and now i need to read files inside network computer drive. 我已经通过下面的代码完成了连接,现在我需要读取网络计算机驱动器中的文件。

import wmi

ip = '192.168.1.18'
username = 'xxxxxx'
password = 'xxxxxx'
connection = wmi.WMI(ip, user=username, password=password)
for disk in connection.Win32_LogicalDisk (DriveType=3):
    print disk.Caption

WMI does not have anything to read/write file content. WMI没有任何内容可读取/写入文件。 You can only read the meta data associated with a file using CIM_DataFile but not the content of the file. 您只能使用CIM_DataFile读取与文件关联的元数据,而不能读取文件的内容。 So, all you need to do is enumerate the files using CIM_DataFile and use one of the shell commands to read the content. 因此,您所需要做的就是使用CIM_DataFile枚举文件,并使用其中一个shell命令读取内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 WMI 和 Python 从远程计算机复制文件并将它们存储在本地计算机中? - How to copy files from remote computer and storing them in local one using WMI and Python? 如何使用 Python 中的 WMI 模块更改计算机的名称 - How do I change a computer's name with the WMI module in Python 如何在python中访问wmi? - How to access wmi in python? 如何在不重新启动计算机的情况下强制Python代码再次读取输入文件 - How can I force Python code to read input files again without rebooting my computer 使用Python的wmi模块删除网络打印机? - Remove a network printer with Python's wmi module? 在远程计算机上使用WMI Python执行系统命令 - Execute system commands using wmi python on remote computer 如何使用Python从网络上的计算机获取本地管理员? - How to use Python to get local admins from a computer on the Network? 如何检查在小型网络中的另一台计算机上是否正在运行相同的python脚本? - How to check if a the same python script is running in another computer in a small network? Python /套接字:如何将文件发送到其他网络上的另一台计算机? - Python/socket: How to send a file to another computer which is on a different network? 如何用 Python Sockets 连接到同一网络上的另一台计算机 - How to connect with Python Sockets to another computer on the same network
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM