or
How to connect remote computer through netuse in python
Before using netuse you should have pywin32 install in your
system with python also.
By Netuse, you can
connect with remote computer. And you can access all data of remote computer. But
it is possible in two ways
1) Mount remote computer drive in local system
2) Connect by virtual connection
Below script will provide accessibility of remote computer
drive
Mount remote computer drive in local system
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”now remote computer drive is mounted in your local sytem you can access easily and if you want to access file then read my next post “how to read files of computer drive in network using python”
Unmount remote computer drive in local system
import win32api import win32net import win32netcon,win32wnet win32wnet.WNetCancelConnection2('\\\\192.168.1.4\\D$',1,1)
Connect remote computer by virtual connection
import win32api import win32net ip = '192.168.1.18' username = 'ram' password = 'ram@123' 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)
Disconnect remote computer by virtual connection
import win32api import win32net win32net.NetUseDel('\\\\192.168.1.18',username,win32net.USE_FORCE)
Thanks Guys
Hi,
ReplyDelete"how to read files of computer drive in network using python" link is broken.
I think it should point to "https://ashishpython.blogspot.com/2013/11/how-to-read-files-of-computer-drive-in.html"