URL='https://www.iconarchive.com/download/i38830/google/chrome/Google-Chrome.ico' # Give the Download icon URL

src_path="C:\ProgramData\website_icons" # Give the preferred path location to save downloaded icon

Display_icon_name="Google" # Enter a name to display below icon on the desktop. Eg: Google chrome 

fileName = 'google.ico'# Give any icon file name as per your wish

Website_To_Open_When_Clicked_On_Icon = "www.google.com" # give here the website to open when user clicks on the shortcut icon

Browser_To_Open_Given_Website = "Chrome" # give Edge or Chrome

Open_the_website_everytime_user_logins = "yes" #give yes or no

import os
import ctypes
import urllib2
import ssl
from datetime import datetime
import shutil

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 check_and_change(icopath, src_path):
    if os.path.exists(icopath):
        print("icon downloaded Path already exists. changing the filename to prevent overwriting")
        dt = datetime.now()
        name = fileName.split('.')
        NewName = name[0] + "_" + dt.strftime(r"%d%m%Y_%H%M%S") + "." + name[-1]
        fp = os.path.join(src_path, NewName)
        return fp
    else:
        return icopath

def Download(src_path, URL):
    print ("Icon Download started")
    icopath = os.path.join(src_path, fileName)
    fp = check_and_change(icopath, src_path)
    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'}
    request = urllib2.Request(URL, headers=headers)
    context = ssl._create_unverified_context()
    parsed = urllib2.urlopen(request, context=context)
    if os.path.exists(src_path):
        print("icon downloaded Path already exists")
    if not os.path.exists(src_path):
        os.makedirs(src_path)
        print("icon downloaded Path created")
    with open(fp, 'wb') as f:
        while True:
            chunk=parsed.read(100*1000*1000)
            if chunk:
                f.write(chunk)
            else:
                break
    print("The file downloaded successfully in specified path")
    return fp

si=Download(src_path, URL)
de= '"'+si+'"'
print(de)

if Browser_To_Open_Given_Website.lower() == "chrome":
    path='"C:\Program Files\Google\Chrome\Application\chrome.exe"'
elif Browser_To_Open_Given_Website.lower() == "edge":
    with disable_file_system_redirection():
        arch=os.popen("wmic os get OSArchitecture").read()
    if '64' in arch:
        path='"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"'
    else:
        path='"C:\Program Files\Microsoft\Edge\Application\msedge.exe"'


vbs='''
Dim WshProcEnv
Dim process_architecture
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("AllUsersDesktop")
Set WshProcEnv = WshShell.Environment("Process")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "\%s.lnk")
process_architecture= WshProcEnv("PROCESSOR_ARCHITECTURE") 
oShellLink.TargetPath = %s
oShellLink.WindowStyle = 1
oShellLink.IconLocation = %s
oShellLink.Hotkey = "CTRL+SHIFT+F"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Arguments = "%s"
oShellLink.Save
'''% (Display_icon_name, path, de, Website_To_Open_When_Clicked_On_Icon)

print(vbs)

def runvbs(vbs):
    workdir=os.environ['PROGRAMDATA']+r'\temp'
    if not os.path.isdir(workdir): 
        os.mkdir(workdir)
    with open(workdir+r'\temprun.vbs',"w") as f :
        f.write(vbs)        
    with disable_file_system_redirection():
        print(os.popen('cscript.exe "'+workdir+r'\temprun.vbs"').read())
        print('Script execution completed successfully')
    if os.path.isfile(workdir+r'\temprun.vbs'):
        os.remove(workdir+r'\temprun.vbs')
    if Open_the_website_everytime_user_logins.lower()=="yes":
        shortcutPath = r"C:\Users\Public\Desktop\%s.lnk"%(Display_icon_name)
        if os.path.exists(shortcutPath):
            shutil.copy2(shortcutPath, r"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp")
        
runvbs(vbs)