By wmi module it's not possible to read all files of network system but we can read by two ways.
1) Mount remote system drive in to your local system.
2) set netuse virtual connection and access to read files.
For mounting remote system drive in your local system, use below code
After connection you can read all files data
2) for set virtual connection use below code
1) Mount remote system drive in to your local system.
2) set netuse virtual connection and access to read files.
For mounting remote system drive in your local system, use below code
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"
After connection you can read all files data
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) for set virtual connection use below code
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"
Hi Guys if these all post are helpful for you then please follow my blog through google plus or Facebook, I will share other useful post for you . If you have any feedback for me please share it.
Thanks guys for your support.
No comments:
Post a Comment