Function PinTo($Shortcut, optional $Action)
dim $path,$objshell,$objfolder,$objFolderitem,$colverbs,$objverb,$verbfound,$location
dim $TaskbarCaptions,$StartMenuCaptions
$TaskbarCaptions = "Pin to Taskbar,An Taskleiste anheften,Épingler à la barre des tâches"
$StartMenuCaptions="Pin to Start Menu,An Startmenü anheften,Épingler au menu Démarrer"
$PinTo=1
if not right($shortcut,3)="lnk"
$shortcut=$shortcut + ".lnk"
endif
if exist($shortcut)
if getfileattr($shortcut) & 16
exit 87
else
$path=left($shortcut,instrrev($shortcut,"\"))
$shortcut=right($shortcut,-instrrev($shortcut,"\"))
endif
else
exit 2
endif
$objShell=CreateObject("Shell.Application")
$objFolder=$objShell.Namespace($path)
$objFolderItem=$objFolder.ParseName($shortcut)
$colVerbs=$objFolderItem.Verbs
for each $objVerb In $colVerbs
if instr(@producttype,"Windows 7") and ($action="" or $action="Taskbar")
$location=$objShell.Namespace(26).self.path + "\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" + $shortcut
if exist($location) and $verbfound=0
exit 80
else
if instr($TaskbarCaptions,join(split($objVerb.name,'&'),'')) and $objVerb.name<>""
$verbfound=1
$objVerb.DoIt
if exist($location)
$PinTo=0
endif
endif
endif
else
$location=$objShell.Namespace(26).self.path + "\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\" + $shortcut
if exist($location) and $verbfound=0
exit 80
else
if instr($StartMenuCaptions,join(split($objVerb.name,'&'),'')) and $objVerb.name<>""
$verbfound=1
$objVerb.DoIt
if exist($location)
$PinTo=0
endif
endif
endif
endif
next
if $verbfound=0
exit 1815
endif
endFunction