Fontpath=r'\\AKITA-PC\latestfonts'
share_user="Akita"
share_pass="comodo"
restart = 0 # give 0 to restart. give 1 if you don't want to restart


import os
import shutil
import ctypes

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)

def copy_and_create_reg(path):
    files = os.listdir(path)
    r = 0
    with disable_file_system_redirection():
        for i in files:
            Name,Extension = os.path.splitext(i)
            if Extension.lower()==".ttf" or Extension.lower()==".otf":
                shutil.copy(path+"\%s"%(i),r"C:\Windows\Fonts")
                print(os.popen('reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "%s (TrueType)" /t REG_SZ /d "%s" /f'%(Name,i)).read())
                print("successfully installed %s"%(i))
        
        if restart==0:
            print("restarting the system")
            print(os.popen("shutdown -r -t 0"))
        elif restart==1:
            print("please restart your system for the changes to take effect")


def run(cmd,Fontpath):    
    workdir=os.environ['PROGRAMDATA']+r'\temp'
    if not os.path.isdir(workdir): 
        os.makedirs(workdir)
    with disable_file_system_redirection():        
        print('Login to network share')
        print(os.popen(cmd).read())
        print('Copying files to local machine....')
        shutil.copytree(Fontpath,workdir+r'\Fonts')      
        copy_and_create_reg(workdir+r'\Fonts')
        shutil.rmtree(workdir)


cmd= 'NET USE "'+Fontpath+'" /USER:'+share_user+'  "'+share_pass+'"'

run(cmd,Fontpath)

