Jump to content

adding items to windows 7 taskbar


Raffle
 Share

Recommended Posts

So i have this function:

Func CreateShortcuts($Skin, $Ver)
    local $DaiLocation = $DaiDirectory & "\daimonin.exe"
    local $XpQuickBarDir = @HomeDrive & "\Documents and Settings\" & @UserName & "\Application Data\Microsoft\Internet Explorer\Quick Launch\Daimonin Client"
    local $XpStartMenu = @HomeDrive & "\Documents and Settings\All Users\Start Menu\Programs\Daimonin\Daimonin Client"
    
    local $7QuickBarDir = @HomeDrive & "\Users\" & @UserName & "\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Daimonin Client"
    local $7StartMenu = @HomeDrive & "\ProgramData\Microsoft\Windows\Start Menu\Programs\Daimonin\Daimonin Client"
    
    If $Ver = "WIN_XP" Then
        if BitAnd(GUICtrlRead($Desktop),$GUI_CHECKED) Then
            FileCreateShortcut($DaiLocation,@DesktopDir & "\Daimonin",$DaiDirectory,"--addon=" & $Skin & ".zip", $Skin & "Skin Shortcut")
        Endif
        if BitAnd(GUICtrlRead($StartMenu),$GUI_CHECKED) Then
            FileCreateShortcut($DaiLocation,$XpStartMenu,$DaiDirectory,"--addon=" & $Skin &".zip", $Skin & "Skin Shortcut")
        Endif
        if BitAnd(GUICtrlRead($QuickBar),$GUI_CHECKED) Then
            FileCreateShortcut($DaiLocation,$XpQuickBarDir,$DaiDirectory,"--addon=" & $Skin & ".zip", $Skin & "Skin Shortcut")
        Endif
    EndIf
    
    If $Ver = "WIN_7" OR "Win_VISTA" Then
        if BitAnd(GUICtrlRead($Desktop),$GUI_CHECKED) Then
            FileCreateShortcut($DaiLocation,@DesktopDir & "\Daimonin",$DaiDirectory,"--addon=" & $Skin & ".zip", $Skin & "Skin Shortcut")
        Endif
        if BitAnd(GUICtrlRead($StartMenu),$GUI_CHECKED) Then
            FileCreateShortcut($DaiLocation,$7StartMenu,$DaiDirectory,"--addon=" & $Skin &".zip", $Skin & "Skin Shortcut")
        Endif
        if BitAnd(GUICtrlRead($QuickBar),$GUI_CHECKED) Then
            FileCreateShortcut($DaiLocation,$7QuickBarDir,$DaiDirectory,"--addon=" & $Skin & ".zip", $Skin & "Skin Shortcut")
        Endif
    EndIf
EndFunc

Now This function works, and does exactly what its supposed too. For the taskbar it puts the file in the right directory, however windows 7 has a weird way of pinning items you need to do more then just add it to the right directory I did some reasearch on it, and its actually extremely complicated, so i was wondering if anyone else wrote something that added an item to a windows 7 taskbar? (without moving the mouse or any cheap hack like that)

Link to comment
Share on other sites

Found these somewhere here and combined the 2 functions...

PinToMenu.au3

#include-once
#include <WinAPI.au3>
#include <Constants.au3>


Func _PinToMenu($File, $Bar = 'Task', $Pin = True)
    If @OSBuild < 7600 Then Return SetError(1) ; Windows 7 only
    If Not FileExists($File) Then Return SetError(2)
    Local $sFolder = StringRegExpReplace($File, "(^.*\\)(.*)", "$1")
    Local $sFile = StringRegExpReplace($File, "^.*\\", '')
    $ObjShell = ObjCreate("Shell.Application")
    $objFolder = $ObjShell.Namespace($sFolder)
    $objFolderItem = $objFolder.ParseName($sFile)
    For $Val In $objFolderItem.Verbs()
        Select
            Case StringInStr($Bar, 'Task')
                If StringInStr($val(), "Tas&kBar") Then
                    $Val.DoIt()
                    Return
                EndIf
            Case StringInStr($Bar, 'Start')
                If StringInStr($val(), "Start Men&u") Then
                    $Val.DoIt()
                    Return
                EndIf
        EndSelect
    Next
EndFunc   ;==>_PinToMenu

Example Script

#include <PinToMenu.au3>


;Pin To Taskbar & Start Menu
_PinToMenu(@WindowsDir & '\notepad.exe', 'Task')
_PinToMenu(@WindowsDir & '\notepad.exe', 'Start')

MsgBox(262144, 'Pause', 'Press OK When ready to remove Notepad')

;Remove From Taskbar & Start Menu
_PinToMenu(@WindowsDir & '\notepad.exe', 'Task', 0)
_PinToMenu(@WindowsDir & '\notepad.exe', 'Start', 0)

Combined Funtions with new input, Task & Start

Edited by Varian
Link to comment
Share on other sites

Found these somewhere here and combined the 2 functions...

PinToMenu.au3

#include-once
#include <WinAPI.au3>
#include <Constants.au3>


Func _PinToMenu($File, $Bar = 'Task', $Pin = True)
    If @OSBuild < 7600 Then Return SetError(1) ; Windows 7 only
    If Not FileExists($File) Then Return SetError(2)
    Local $sFolder = StringRegExpReplace($File, "(^.*\\)(.*)", "$1")
    Local $sFile = StringRegExpReplace($File, "^.*\\", '')
    $ObjShell = ObjCreate("Shell.Application")
    $objFolder = $ObjShell.Namespace($sFolder)
    $objFolderItem = $objFolder.ParseName($sFile)
    For $Val In $objFolderItem.Verbs()
        Select
            Case StringInStr($Bar, 'Task')
                If StringInStr($val(), "Tas&kBar") Then
                    $Val.DoIt()
                    Return
                EndIf
            Case StringInStr($Bar, 'Start')
                If StringInStr($val(), "Start Men&u") Then
                    $Val.DoIt()
                    Return
                EndIf
        EndSelect
    Next
EndFunc   ;==>_PinToMenu

Example Script

#include <PinToMenu.au3>


;Pin To Taskbar & Start Menu
_PinToMenu(@WindowsDir & '\notepad.exe', 'Task')
_PinToMenu(@WindowsDir & '\notepad.exe', 'Start')

MsgBox(262144, 'Pause', 'Press OK When ready to remove Notepad')

;Remove From Taskbar & Start Menu
_PinToMenu(@WindowsDir & '\notepad.exe', 'Task', 0)
_PinToMenu(@WindowsDir & '\notepad.exe', 'Start', 0)

Combined Funtions with new input, Task & Start

Thank you, i actually found that after i posted (well just for pinning to taskbar) Next time ill do a better job of looking first, i have one more question tho, does Vista use the same system as 7? or does it just use a directory only system like windows xp?
Link to comment
Share on other sites

I believe it is compatible with XP...I know Vista does not have the Windows 7 SuperBar(Taskbar) native.

@Varian

Doesn't work on XP Sp3

I add If $Val() <> '' Then ConsoleWrite ( $Val() & @Crlf ) to your script

and it give me all items of the right click context menu , but nothing about taskbar !

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

@Varian

Doesn't work on XP Sp3

I add If $Val() <> '' Then ConsoleWrite ( $Val() & @Crlf ) to your script

and it give me all items of the right click context menu , but nothing about taskbar !

The script I posted is only intended for Windows 7. When I said that it was compatible with XP, I was answering a question by the OP.

It (Vista) is compatible (should have used comparable) with XP in the fact that you just need to make the shortcuts in the appropriate directory. Sorry for the confusion!

Link to comment
Share on other sites

  • 7 months later...

I know this is an old topic, but I just stumbled across it looking for info about this topic, and I figure this may be of use to others that find it in a search.

The function posted by Varian works great (and thank you very much), but it's incomplete. The third argument, which appears to be used to determine whether an item is pinned or unpinned, isn't actually implemented. The result is that the function acts like a toggle - if the item is not pinned, it will be added; if the item is pinned, it will be removed. If you want to specifically remove something and it's not currently there, you'll just end up adding it instead.

I updated the function to properly support this. Now, if $pin = true (default), the item will always only be added, and likewise $pin = false will cause the item to always only be removed. I had also converted the function to my personal style in the process, and I know it's not the preferred style for the forum, so apologies to anyone inconvenienced by that.

Hope this helps.

func pinitem($file, $loc = 'task', $pin = true)
    if @OSBuild < 7600 then return seterror(1) ; Windows 7 only
    if not fileexists($file) then return seterror(2)
    local $sFolder = stringregexpreplace($file, "(^.*\\)(.*)", "$1")
    local $sFile = stringregexpreplace($file, "^.*\\", '')
    $ObjShell = objcreate("Shell.Application")
    $objFolder = $ObjShell.Namespace($sFolder)
    $objFolderItem = $objFolder.ParseName($sFile)
    For $Val in $objFolderItem.Verbs()
        if $pin then
            if $loc = 'task' and $val() = "Pin to Tas&kBar" then
                $Val.DoIt()
                return
            elseif $loc = 'start' and $val() = "Pin to Start Men&u" then
                $Val.DoIt()
                return
            endif
        else
            if $loc = 'task' and $val() = "Unpin from Tas&kBar" then
                $Val.DoIt()
                return
            elseif $loc = 'start' and $val() = "Unpin from Start Men&u" then
                $Val.DoIt()
                return
            endif
        endif
    next
endfunc
Link to comment
Share on other sites

  • 2 months later...

Found these somewhere here and combined the 2 functions...

PinToMenu.au3

#include-once
#include <WinAPI.au3>
#include <Constants.au3>


Func _PinToMenu($File, $Bar = 'Task', $Pin = True)
    If @OSBuild < 7600 Then Return SetError(1) ; Windows 7 only
    If Not FileExists($File) Then Return SetError(2)
    Local $sFolder = StringRegExpReplace($File, "(^.*\\)(.*)", "$1")
    Local $sFile = StringRegExpReplace($File, "^.*\\", '')
    $ObjShell = ObjCreate("Shell.Application")
    $objFolder = $ObjShell.Namespace($sFolder)
    $objFolderItem = $objFolder.ParseName($sFile)
    For $Val In $objFolderItem.Verbs()
        Select
            Case StringInStr($Bar, 'Task')
                If StringInStr($val(), "Tas&kBar") Then
                    $Val.DoIt()
                    Return
                EndIf
            Case StringInStr($Bar, 'Start')
                If StringInStr($val(), "Start Men&u") Then
                    $Val.DoIt()
                    Return
                EndIf
        EndSelect
    Next
EndFunc   ;==>_PinToMenu

Example Script

#include <PinToMenu.au3>


;Pin To Taskbar & Start Menu
_PinToMenu(@WindowsDir & '\notepad.exe', 'Task')
_PinToMenu(@WindowsDir & '\notepad.exe', 'Start')

MsgBox(262144, 'Pause', 'Press OK When ready to remove Notepad')

;Remove From Taskbar & Start Menu
_PinToMenu(@WindowsDir & '\notepad.exe', 'Task', 0)
_PinToMenu(@WindowsDir & '\notepad.exe', 'Start', 0)

Combined Funtions with new input, Task & Start

Hi,

I'm trying to add some links into startmenu and taskbar, but your script doesn't do anything here. windows7 pro x64. any thing I should be aware of ?

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Link to comment
Share on other sites

ok, I had to put menus in french as my windows is french, now it works.

But with both script (Varian and nitro322) if I use it to remove a shortcut that isn't there, it create it. I have several machines on which to do this, some has it and others not. Maybe I can add a check in C:\Users\**user**\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu to first check if it's there, will try that.

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Link to comment
Share on other sites

ok, I had to put menus in french as my windows is french, now it works.

But with both script (Varian and nitro322) if I use it to remove a shortcut that isn't there, it create it. I have several machines on which to do this, some has it and others not. Maybe I can add a check in C:\Users\**user**\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu to first check if it's there, will try that.

And what about the post directly above yours where that problem was supposedly fixed?

:)

Link to comment
Share on other sites

My own, I used too short menu description for the function to search. All is fine now, translated entire phrase in french and it works like charm :-) I use nitro322 version, which indeed add OR remove, no toggle.

Once more, many thanks to this very active community, autoit rocks !

Edited by kiboost

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Link to comment
Share on other sites

  • 3 weeks later...

Thanks for this topic, and all those which link to it.

Nevertheless I feel it misses something... Kiboost did tell it without telling it: these text Verbs() are localized.

As I like to do world-apps, at least at usage level, here is the way I found to get the current system strings from Windows shell32.dll (thanks to google I found and this here by searching "Pin to Tas&kbar" : http://www.win7dll.info/shell32_dll.html).

Thanks to all involved people.

The code below allows to pin or unpin to/from Start Menu or TaskBar, and allows to define argument(s) for pinned applications, in any language.

As I don't have a Enterprise or Ultimate Windows Seven, I wasn't able to test if this was suitable to each and every localized Windows 7, but as I'm confident Windows doesn't work by magic, it should be international. But, as a matter of fact, Windows is sometimes strange, so I would like Spanish, Russian, Endian and any other language than French to be confirmed as working with this method, if you're kind enough to do so, thanks.

#include-once
#include <WinAPI.au3>
#include <Constants.au3>

Func _pinunpin($filepath, $action = 'p2sm', $arguments = '')
    $clean = 0
    If Not FileExists($filepath) Or @OSBuild < 7600 Then Exit ; to arrange to your liking, SetError() & co

    ;split path, filename and extension
    $pathsplit = StringSplit($filepath, '\')
    $lastp = $pathsplit[0]
    $file = $pathsplit[$lastp]
    $path = StringReplace($filepath, $file, '')
    $path = StringTrimRight($path, 1)
    $filesplit = StringSplit($file, ".")
    $last = $filesplit[0]
    $fileext = $filesplit[$last]
    $filename = StringReplace($file, '.' & $fileext, '', 1)

    ;define code to use depending on action choosen
    Switch $action
        Case 'pin2SM', 'p2sm'           ;pin to Start Menu
            $code = 5381
        Case 'unpinFromSM', 'up2sm'     ;unpin from Start Menu
            $code = 5382
        Case 'pin2TB', 'p2tb'           ;pin to Task Bar
            $code = 5386
        Case 'unpinFromTB', 'up2tb'     ;unpin from Task Bar
            $code = 5387
    EndSwitch

    ;if arguments, make a shortcut, pin it then mark it for deletion
    If $arguments <> '' And $code <> 5382 And $code <> 5387 Then
        $linkfile = @DesktopDir & '\' & $filename & '.lnk'
        FileCreateShortcut($filepath, $linkfile, $path, $arguments, $filename & ' ' & $arguments, $filepath)
        $path = @DesktopDir
        $file = $filename & '.lnk'
        $clean = 1
    EndIf

    ;retrieve Localized text for action
    $hInstance = _WinAPI_LoadLibraryEx('shell32.dll', $LOAD_LIBRARY_AS_DATAFILE)
    If $hInstance Then
        $localizedstring = _WinAPI_LoadString($hInstance, $code)
        ;If @error Then MsgBox(0, "Error", _WinAPI_GetLastErrorMessage()) ;debug
        _WinAPI_FreeLibrary($hInstance)
    EndIf

    ;when unpining from Start Menu, use the shortcut that is effectively pinned to do so, if argument(s) they are ignored
    If $code == 5382 Then
        $path = @UserProfileDir & '\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu'
        $file = $filename & '.lnk'
    EndIf

    ;pin or unpin
    $objShell = ObjCreate('Shell.Application')
    $objFolder = $objShell.Namespace($path)
    $objFolderItem = $objFolder.ParseName($file)
    For $val in $objFolderItem.Verbs()
        If StringInStr($val(), $localizedstring) Then $val.DoIt()
    Next

    ;clean temporary shortcut
    If $clean Then
        FileDelete($linkfile)
    EndIf
EndFunc


;usage
_pinunpin('C:\Windows\System32\calc.exe')   ;pin Windows' calculator to taskbar.
_pinunpin('C:\Windows\System32\notepad.exe', 'p2tb', 'C:\Windows\system.ini') ;pin notepad to start menu with system.ini file as argument (completely useless, but this file should be on any win7)

This code can't switch between pin/unpin, you have to tell it the right action to do, or adapt the Switch part to enable unpin/pin switching.

Edited by AvvA
Link to comment
Share on other sites

  • 1 year later...

Thanks for this topic, and all those which link to it.

Nevertheless I feel it misses something... Kiboost did tell it without telling it: these text Verbs() are localized.

As I like to do world-apps, at least at usage level, here is the way I found to get the current system strings from Windows shell32.dll (thanks to google I found and this here by searching "Pin to Tas&kbar" : http://www.win7dll.info/shell32_dll.html).

Thanks to all involved people.

The code below allows to pin or unpin to/from Start Menu or TaskBar, and allows to define argument(s) for pinned applications, in any language.

As I don't have a Enterprise or Ultimate Windows Seven, I wasn't able to test if this was suitable to each and every localized Windows 7, but as I'm confident Windows doesn't work by magic, it should be international. But, as a matter of fact, Windows is sometimes strange, so I would like Spanish, Russian, Endian and any other language than French to be confirmed as working with this method, if you're kind enough to do so, thanks.

#include-once
#include <WinAPI.au3>
#include <Constants.au3>

Func _pinunpin($filepath, $action = 'p2sm', $arguments = '')
    $clean = 0
    If Not FileExists($filepath) Or @OSBuild < 7600 Then Exit ; to arrange to your liking, SetError() & co

    ;split path, filename and extension
    $pathsplit = StringSplit($filepath, '\')
    $lastp = $pathsplit[0]
    $file = $pathsplit[$lastp]
    $path = StringReplace($filepath, $file, '')
    $path = StringTrimRight($path, 1)
    $filesplit = StringSplit($file, ".")
    $last = $filesplit[0]
    $fileext = $filesplit[$last]
    $filename = StringReplace($file, '.' & $fileext, '', 1)

    ;define code to use depending on action choosen
    Switch $action
        Case 'pin2SM', 'p2sm'           ;pin to Start Menu
            $code = 5381
        Case 'unpinFromSM', 'up2sm'     ;unpin from Start Menu
            $code = 5382
        Case 'pin2TB', 'p2tb'           ;pin to Task Bar
            $code = 5386
        Case 'unpinFromTB', 'up2tb'     ;unpin from Task Bar
            $code = 5387
    EndSwitch

    ;if arguments, make a shortcut, pin it then mark it for deletion
    If $arguments <> '' And $code <> 5382 And $code <> 5387 Then
        $linkfile = @DesktopDir & '\' & $filename & '.lnk'
        FileCreateShortcut($filepath, $linkfile, $path, $arguments, $filename & ' ' & $arguments, $filepath)
        $path = @DesktopDir
        $file = $filename & '.lnk'
        $clean = 1
    EndIf

    ;retrieve Localized text for action
    $hInstance = _WinAPI_LoadLibraryEx('shell32.dll', $LOAD_LIBRARY_AS_DATAFILE)
    If $hInstance Then
        $localizedstring = _WinAPI_LoadString($hInstance, $code)
        ;If @error Then MsgBox(0, "Error", _WinAPI_GetLastErrorMessage()) ;debug
        _WinAPI_FreeLibrary($hInstance)
    EndIf

    ;when unpining from Start Menu, use the shortcut that is effectively pinned to do so, if argument(s) they are ignored
    If $code == 5382 Then
        $path = @UserProfileDir & '\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu'
        $file = $filename & '.lnk'
    EndIf

    ;pin or unpin
    $objShell = ObjCreate('Shell.Application')
    $objFolder = $objShell.Namespace($path)
    $objFolderItem = $objFolder.ParseName($file)
    For $val in $objFolderItem.Verbs()
        If StringInStr($val(), $localizedstring) Then $val.DoIt()
    Next

    ;clean temporary shortcut
    If $clean Then
        FileDelete($linkfile)
    EndIf
EndFunc


;usage
_pinunpin('C:\Windows\System32\calc.exe')   ;pin Windows' calculator to taskbar.
_pinunpin('C:\Windows\System32\notepad.exe', 'p2tb', 'C:\Windows\system.ini') ;pin notepad to start menu with system.ini file as argument (completely useless, but this file should be on any win7)

This code can't switch between pin/unpin, you have to tell it the right action to do, or adapt the Switch part to enable unpin/pin switching.

awsome script .might even be my solution ...

but

it doesnt work to pin FOLDER to start menu ?

can you adapt it so it work ? , please

i confirm the "verbs" work . my windows 7 is french

Link to comment
Share on other sites

  • 2 years later...

#RequireAdmin

#include <WinAPI.au3>
#include <Constants.au3>

Func _pinunpin($filepath, $action = 'p2tb', $arguments = '')
    $clean = 0
    If Not FileExists($filepath) Or @OSBuild < 7600 Then Exit ; to arrange to your liking, SetError() & co
        ;split path, filename and extension
    $pathsplit = StringSplit($filepath, '\')
    $lastp = $pathsplit[0]
    $file = $pathsplit[$lastp]
    $path = StringReplace($filepath, $file, '')
    $path = StringTrimRight($path, 1)
    $filesplit = StringSplit($file, ".")
    $last = $filesplit[0]
    $fileext = $filesplit[$last]
    $filename = StringReplace($file, '.' & $fileext, '', 1)

    ;define code to use depending on action choosen
    Switch $action
        Case 'pin2SM', 'p2sm' ;pin to Start Menu
            $code = 5381
        Case 'unpinFromSM', 'up2sm' ;unpin from Start Menu
            $code = 5382
        Case 'pin2TB', 'p2tb' ;pin to Task Bar
            $code = 5386
        Case 'unpinFromTB', 'up2tb' ;unpin from Task Bar
            $code = 5387
    EndSwitch

    ;if arguments, make a shortcut, pin it then mark it for deletion
    If $arguments <> '' And $code <> 5382 And $code <> 5387 Then
        $linkfile = @DesktopDir & '\' & $filename & '.lnk'
        FileCreateShortcut($filepath, $linkfile, $path, $arguments, $filename & ' ' & $arguments, $filepath)
        $path = @DesktopDir
        $file = $filename & '.lnk'
        $clean = 1
    EndIf

    ;retrieve Localized text for action
    $hInstance = _WinAPI_LoadLibraryEx('shell32.dll', $LOAD_LIBRARY_AS_DATAFILE)
    If $hInstance Then
        $localizedstring = _WinAPI_LoadString($hInstance, $code)
        If @error Then MsgBox(0, "Error", _WinAPI_GetLastErrorMessage()) ;debug
        _WinAPI_FreeLibrary($hInstance)
    EndIf

    ;when unpining from Start Menu, use the shortcut that is effectively pinned to do so, if argument(s) they are ignored
    If $code == 5382 Then
        $path = @UserProfileDir & '\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu'
        $file = $filename & '.lnk'
    EndIf

    ;pin or unpin
    $objShell = ObjCreate('Shell.Application')
    $objFolder = $objShell.Namespace($path)
    $objFolderItem = $objFolder.ParseName($file)
    For $val In $objFolderItem.Verbs()
        If StringInStr($val(), $localizedstring) Then $val.DoIt()
    Next

    ;clean temporary shortcut
    If $clean Then
        FileDelete($linkfile)
    EndIf
EndFunc   ;==>_pinunpin

$file = 'C:\program files\Internet Explorer\iexplore.exe'
 _pinunpin($file)

 

this works fine on Windows 8.1 but not on win10, does anyone know a way to pin ie to the taskbar?

Link to comment
Share on other sites

I use this on windows 10

$objShell = ObjCreate("Shell.Application")
$objFSO = ObjCreate("Scripting.FileSystemObject")
$strlPath = "C:\Users\RAZIEL\Desktop\Nuevo AutoIt v3 Script.exe"
$strFolder = $objFSO.GetParentFolderName($strlPath)
$strFile = $objFSO.GetFileName($strlPath)
$objFolder = $objShell.Namespace($strFolder)
$objFolderItem = $objFolder.ParseName($strFile)
$colVerbs = $objFolderItem.Verbs
For $itemverb in $objFolderItem.verbs
    If StringReplace($itemverb.name, "&", "") = "Pin to Taskbar" Then $itemverb.DoIt
Next

But is not dinamically. this one work for English OS.

 Saludos

Link to comment
Share on other sites

thanks, but i can not make it work in german OS, any ideas?

 

$objShell = ObjCreate("Shell.Application")
$objFSO = ObjCreate("Scripting.FileSystemObject")
;$strlPath = 'C:\program files (x86)\Internet Explorer\iexplore.exe'
$strlPath = 'C:\program files\Internet Explorer\iexplore.exe'
$strFolder = $objFSO.GetParentFolderName($strlPath)
$strFile = $objFSO.GetFileName($strlPath)
$objFolder = $objShell.Namespace($strFolder)
$objFolderItem = $objFolder.ParseName($strFile)
$colVerbs = $objFolderItem.Verbs

For $itemverb In $objFolderItem.verbs
    ;MsgBox(0,"",StringReplace($itemverb.name,"&",""))
    If StringInStr(StringReplace($itemverb.name,"&",""), "Taskleiste anheften") Then $itemverb.DoIt
Next

 

EDIT: changed code, still not working in win10, when i use the message box to see what options exist, the pin to taskbar option ist not coming up, so it can not be selected...

Edited by Allow2010
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...