link="192.168.1.7" #ip or ftp name
user="ftp-user" #user
password="test" #password
file_download_path="ftp://192.168.1.7/test" #downoadpath
file_save_path=r"C:/Users" #savepath
filename="putty.msi" #filename
import os
import ctypes
from subprocess import Popen,PIPE

file_download_path_1=file_download_path+"/"+filename
file_save_path_1=file_save_path+"/"+filename
commands='curl -u "%s":%s "%s" -o "%s"'%(user,password,file_download_path_1,file_save_path_1)
class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
    def __enter__(self):
        self.old_value = ctypes.c_long()
        self.success = self._disable(ctypes.byref(self.old_value))
    def __exit__(self, type, value, traceback):
        if self.success:
            self._revert(self.old_value)
with disable_file_system_redirection():
    #print commands
    os.chdir("C:\Windows\Temp")
    with open("ftp.bat","w") as f:
        f.write(commands)
    p=Popen("ftp.bat",stdout=PIPE,stdin=PIPE)
    r,e=p.communicate()
    if e:
        print e
    else:
        print r
#    print os.popen(commands).read()
    
    os.chdir(file_save_path)
    print os.popen("msiexec /i "+filename+" /qn ").read()
    print "Successfully installed"
    