restart = 1 # give 1 to restart. give 0 if you don't want to restart. but restart is necessary for the changes to take effect.

import os
from subprocess import PIPE, Popen
import ctypes
import ssl
import urllib2

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():
    arch=os.popen("wmic os get OSArchitecture").read()

if '64' in arch:
    url="https://script-downloads.comodo.com/forticlient-6.4.8/64bit/FortiClientVPNSetup_6.4.8.1755_x64.exe"
else:
    url="https://script-downloads.comodo.com/forticlient-6.4.8/32bit/FortiClientVPNSetup_6.4.8.1755_x86.exe"

Down_path=os.environ['TEMP']
fileName = url.split('/')[-1]
DownTo = os.path.join(Down_path, fileName)

def downloadFile(DownTo, fromURL):
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}
    context = ssl._create_unverified_context()
    request = urllib2.Request(fromURL, headers=headers)
    req = urllib2.urlopen(request,context=context)
    try:
        with open(DownTo, 'wb') as f:
            while True:
                chunk = req.read(100*1000*1000)
                if chunk:
                    f.write(chunk)
                else:
                    break
        if os.path.isfile(DownTo):
            return '{} - {}KB'.format(DownTo, os.path.getsize(DownTo)/1024)
		
    except:
        return 'Please Check URL or Download Path!'

print(downloadFile(DownTo, url))

with disable_file_system_redirection():
    if os.path.exists(DownTo):
            ec=DownTo+" /quiet /norestart"
            OBJ = Popen(ec, shell = True, stdout = PIPE, stderr = PIPE)
            out, err = OBJ.communicate()
            RET = OBJ.returncode
            if RET == 0:
                print(os.popen("sc config FA_Scheduler start=auto").read())
                if restart:
                    print("restarting the system")
                    print(os.popen("shutdown -r").read())
                else:
                    print "ForticlientVPN 6.4.8.1755 has been installed, please restart the system"
            else:
                print "ForticlientVPN 6.4.8.1755 could not able to install"

    else:
        print "Please check the path"
        
os.remove(DownTo)