Created
August 12, 2018 14:34
-
-
Save nagasudhirpulla/4057cd897104e644dd020c5fbabea91d to your computer and use it in GitHub Desktop.
python file transfer in network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Sun Aug 12 19:22:37 2018 | |
@author: Nagasudhir | |
https://ashishpython.blogspot.com/2013/11/how-to-connect-one-computer-to-another_1.html?m=1 | |
https://www.howtogeek.com/howto/16196/how-to-disconnect-non-mapped-unc-path-drives-in-windows/ | |
http://baloncoding.blogspot.com/2013/11/disconnect-and-map-network-drive-on.html | |
""" | |
import win32api | |
import win32net | |
import shutil | |
import subprocess | |
ip = '192.168.1.18' | |
username = 'username' | |
password = 'pass' | |
use_dict={} | |
use_dict['remote']=unicode(r'\\192.168.137.1\Users') | |
use_dict['password']=unicode(password) | |
use_dict['username']=unicode(username) | |
win32net.NetUseAdd(None, 2, use_dict) | |
srcFile = r'C:\Users\Nagasudhir\Downloads\myFile.txt' | |
dest_dir = r'\\192.168.137.1\Users\Nagasudhir\Downloads\Video' | |
shutil.copy(srcFile, dest_dir) | |
winCMD = r'NET USE /delete \\192.168.137.1\Users' | |
print(winCMD) | |
subprocess.call(winCMD, shell=True) | |
# win32net.NetUseDel(r'\\192.168.137.1\Users',username,win32net.USE_FORCE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment