Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
读取所有系统';使用python在网络中驱动数据_Python_Wmi - Fatal编程技术网

读取所有系统';使用python在网络中驱动数据

读取所有系统';使用python在网络中驱动数据,python,wmi,Python,Wmi,我正在使用python制作一个应用程序。因为我无法读取远程系统的文件数据。有人告诉我如何使用python读取网络中的所有计算机数据 我使用wmi模块进行了远程连接,但通过wmi,我无法访问远程计算机数据 import wmi ip = '192.168.3.124' username = 'example' password = 'example' try: connection = wmi.WMI(ip, user=username, password=password) except

我正在使用python制作一个应用程序。因为我无法读取远程系统的文件数据。有人告诉我如何使用python读取网络中的所有计算机数据

我使用wmi模块进行了远程连接,但通过wmi,我无法访问远程计算机数据

import wmi

ip = '192.168.3.124'
username = 'example'
password = 'example'
try:
   connection = wmi.WMI(ip, user=username, password=password)
except:
   print "connection failed"

wmi模块不可能读取网络系统的所有文件,但我们可以通过两种方式读取

1) 将远程系统驱动器装入本地系统

2) 设置netuse虚拟连接和访问文件

要在本地系统中安装远程系统驱动器,请使用以下代码

import win32api
import win32net
import win32netcon,win32wnet

username='user'
password='psw'

try:
    win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, 'Z:','\\\\192.168.1.18\\D$', None, username,password, 0)
    print "connection established successfully"
except:
    print  "connection not established"
import win32api
import win32net

ip = '192.168.1.18'
username = 'ram'
password = 'ram@123'

try:
    use_dict={}
    use_dict['remote']=unicode('\\\\192.168.1.18\C$')
    use_dict['password']=unicode(password)
    use_dict['username']=unicode(username)
    win32net.NetUseAdd(None, 2, use_dict)
except:
    print  "connection not established"
连接后,您可以读取所有文件数据

for root, dirnames, filenames in os.walk('\\\\192.168.1.18\D$'):
        for filename in filenames:
            match=os.path.join(root, filename)
            datafile = file(match)
            for line in datafile:
               print line
2)对于设置虚拟连接,请使用下面的代码

import win32api
import win32net
import win32netcon,win32wnet

username='user'
password='psw'

try:
    win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, 'Z:','\\\\192.168.1.18\\D$', None, username,password, 0)
    print "connection established successfully"
except:
    print  "connection not established"
import win32api
import win32net

ip = '192.168.1.18'
username = 'ram'
password = 'ram@123'

try:
    use_dict={}
    use_dict['remote']=unicode('\\\\192.168.1.18\C$')
    use_dict['password']=unicode(password)
    use_dict['username']=unicode(username)
    win32net.NetUseAdd(None, 2, use_dict)
except:
    print  "connection not established"

我用code
except
编辑了我的文章?你测试过这个吗?我打字时出错了。除了,它是
。它在工作,我可以阅读,但我不想安装在本地系统中。你能描述一下虚拟网络用户吗?我已经更新了虚拟网络用户连接的代码。现在您可以访问网络中的所有计算机数据。