#To define a particular parameter, replace the 'parameterName' inside itsm.getParameter('variableName') with that parameter's name 
iconname=itsm.getParameter('Shortcut_Name') #provide the shortcut icon name as Shortcut_Name parameter eg. comodo
target_path=itsm.getParameter('Application_path') #provide the browser path here as Application_path parameter eg. C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
iconpath=itsm.getParameter('iconpath') #provide the path where your icon image is located as parameter eg. C:\Users\images\logo.ico


import os
import shutil 
import getpass 
import ctypes 
import platform
from subprocess import PIPE, Popen

arch= platform.machine()
quick_icon_name=iconname
path=r'C:\Users\Public\Desktop'
found=0
def ecmd(command):
    import ctypes
    from subprocess import PIPE, Popen
    
    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():
        obj = Popen(command, shell = True, stdout = PIPE, stderr = PIPE)
    out, err = obj.communicate()
    ret=obj.returncode
    if ret==0:
        if out:
            return out.strip()
        else:
            return ret
    else:
        if err:
            return err.strip()
        else:
            return ret
for i in os.listdir(path):
    if quick_icon_name.lower() == i.lower():
        cmd1='del '+'"'+path+'\\'+quick_icon_name+'"'
        print ecmd(cmd1)
        if os.path.isfile(os.path.join(path, i)):
            print 'Removing the Quick Icon "%s" is Failed'%quick_icon_name
        else:
            found+=1
            print 'The Quick Icon "%s" is Removed'%quick_icon_name
    else:
        found+=0

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():
    sh_path = 'C:\\Users\\Public\\Desktop\\'+ iconname +'.lnk'
    ic_path = '$IconLocation = '+'"'+ iconpath+'"'
    exe_file = '$Shortcut.TargetPath = '+'"'+target_path+'"'
    cmds = '$ShortcutPath = '+'"'+sh_path+'"'+'; '+'$IconLocation = '+'"'+ iconpath+'"'+'; '+'$Shell = New-Object -ComObject ("WScript.Shell")'+'; '+'$Shortcut = $Shell.CreateShortcut($ShortcutPath)'+'; '+'$Shortcut.TargetPath = '+'"'+target_path+'"'+'; '+'$Shortcut.IconLocation = "$IconLocation"'+'; '+'$Shortcut.Save()'
    cmd = Popen(['powershell',cmds], shell = True, stdout = PIPE, stderr = PIPE)
    res,err = cmd.communicate()
    if err:
        print err
    else:
        print (iconname +" "+"shortcut created successfully")
        