#198755 - 2010-06-02 12:21 AM
Re: Pinning Shortcuts to taskbar Windows7
[Re: Allen]
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
I used something like this on XP, not sure if its needed or can be modified to work on Windows 7 or not.
Function AddToMyNetworkPlaces($Name,$Location,Optional $Comment)
Dim $Nethood,$Shell,$S,$D,$T
$AddToMyNetworkPlaces=1
If Exist($Location)
$Nethood=ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders','NetHood')
If GetFileAttr($Nethood+'\'+$Name) & 16
; 'Link exists already. Exit the function.
Exit 80
EndIf
MD $Nethood+'\'+$Name
$D=$Nethood+'\'+$Name+'\'+'Desktop.ini'
$T=$Nethood+'\'+$Name+'\'+'target.lnk'
$S = SetFileAttr($Nethood+'\'+$Name,1)
$S = WriteProfileString ($D,'.ShellClassInfo','CLSID2','{0AFACED1-E828-11D1-9187-B532F1E9575D}')
$S = WriteProfileString ($D,'.ShellClassInfo','FLAGS','2')
$S = SetFileAttr($D,6)
$Shell = CreateObject('wscript.shell')
If @ERROR Exit @ERROR EndIf
$S = $Shell.CreateShortcut($T)
$S.TargetPath = $Location
$S.WorkingDirectory = $Location
If $Comment
$S.Description = $Comment
EndIf
$S.Save
If @ERROR Exit @ERROR Else $AddToMyNetworkPlaces=0 EndIf
Else
Exit 3
EndIf
EndFunction
|
|
Top
|
|
|
|
#198770 - 2010-06-04 09:49 AM
Re: Pinning Shortcuts to taskbar Windows7
[Re: nocke62]
|
nocke62
Fresh Scripter
Registered: 2005-03-30
Posts: 12
Loc: Ratingen, Germany
|
Here is what I have changed for the german version: Replace the "Action" with the correct words, depending on the OS Language.
if instr(@producttype,"Windows 7") and ($action="" or $action="Taskbar")
; $action="Pin to Taskbar"
$action="An Taskleiste anheften"
$location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" + $shortcut
else
; $action="Pin to Start Menu"
$action="An Startmenü anheften"
$location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\" + $shortcut
endif
Maybe, it's possible to check the OS language and replace the action with language depended content, before running this part of the function.
|
|
Top
|
|
|
|
#198776 - 2010-06-05 08:27 PM
Re: Pinning Shortcuts to taskbar Windows7
[Re: Allen]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4574
Loc: USA
|
@nocke or anyone with a German version of the OS... could you test this. If it doesn't work, please provide what @syslang is in your language. Thanks.
Function PinTo($Shortcut, optional $Action)
dim $Languages[1]
$Languages[0]="0409English,Pin to Taskbar,Pin to Start Menu"
$Languages[1]="0407German,An Taskleiste anheften,An Startmenü anheften"
dim $path,$objshell,$objfolder,$objFolderitem,$colverbs,$objverb,$location,$langid
$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
$langid=ascan($languages,@syslang,,,1)
if $langid>-1
if instr(@producttype,"Windows 7") and ($action="" or $action="Taskbar")
$action=split($languages[$langid],",")[1]
$location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" + $shortcut
else
$action=split($languages[$langid],",")[2]
$location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\" + $shortcut
endif
else
exit 1815
endif
$objShell=CreateObject("Shell.Application")
$objFolder=$objShell.Namespace($path)
$objFolderItem=$objFolder.ParseName($shortcut)
$colVerbs=$objFolderItem.Verbs
for each $objVerb In $colVerbs
if join(split($objVerb.name,'&'),'')=$action
$objVerb.DoIt
if exist($objShell.Namespace(26).self.path + $location)
$PinTo=0
else
exit 82
endif
endif
next
endFunction
_________________________
(... better days ahead)
|
|
Top
|
|
|
|
#198798 - 2010-06-08 03:57 PM
Re: Pinning Shortcuts to taskbar Windows7
[Re: nocke62]
|
Darknoon
Fresh Scripter
Registered: 2005-03-24
Posts: 9
|
Hi ! Not working for me, with french Pro W7. @syslang return "0409English", @error/@serror return 0/l'opération a réussi
in french (but not working) : $action = Épingler à la barre des tâches $action = Épingler au menu Démarrer
|
|
Top
|
|
|
|
#198800 - 2010-06-08 04:08 PM
Re: Pinning Shortcuts to taskbar Windows7
[Re: Allen]
|
Darknoon
Fresh Scripter
Registered: 2005-03-24
Posts: 9
|
@Userlang return 040CFrench for me
|
|
Top
|
|
|
|
#198801 - 2010-06-08 04:24 PM
Re: Pinning Shortcuts to taskbar Windows7
[Re: Darknoon]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4574
Loc: USA
|
ah-ha... so let's try this. I also think I need to check if the pinned icon is already there (add that later). I'm also not sure how well kix handles these special characters in your languages. I guess we'll figure it out.
Function PinTo($Shortcut, optional $Action)
dim $Languages[2]
$Languages[0]="0409English,Pin to Taskbar,Pin to Start Menu"
$Languages[1]="0407German,An Taskleiste anheften,An Startmenü anheften"
$Languages[2]="040CFrench,Épingler à la barre des tâches,Épingler au menu Démarrer"
dim $path,$objshell,$objfolder,$objFolderitem,$colverbs,$objverb,$location,$langid
$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
$langid=ascan($languages,@userlang,,,1)
if $langid>-1
if instr(@producttype,"Windows 7") and ($action="" or $action="Taskbar")
$action=split($languages[$langid],",")[1]
$location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" + $shortcut
else
$action=split($languages[$langid],",")[2]
$location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\" + $shortcut
endif
else
exit 1815
endif
$objShell=CreateObject("Shell.Application")
$objFolder=$objShell.Namespace($path)
$objFolderItem=$objFolder.ParseName($shortcut)
$colVerbs=$objFolderItem.Verbs
for each $objVerb In $colVerbs
if join(split($objVerb.name,'&'),'')=$action
$objVerb.DoIt
if exist($objShell.Namespace(26).self.path + $location)
$PinTo=0
else
exit 82
endif
endif
next
endFunction
Edited by Allen (2010-06-08 04:32 PM)
_________________________
(... better days ahead)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1383 anonymous users online.
|
|
|