How To Pin To Start Special Folders With No Target

Viewed 550

How do you pin to start special folders using powershell? Like "ThisPC", iexplorer

This will pin to start exe's fine, but what about windows explorer and myComputer? How to pin those items since they have no target?

Given this

 <start:DesktopApplicationTile Size="2x2" Column="0" Row="0" DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\Windows System\This PC.lnk" />

It seems to have issues with .lnk's for "This PC", "File Explorer", etc

Function PinLnk
{
    Param
    (
        [Parameter(Mandatory,Position=0)]
        [Alias('p')]
        [String[]]$Path
    )
    $Shell = New-Object -ComObject Shell.Application
    $Desktop = $Shell.NameSpace(0X0)
    $WshShell = New-Object -comObject WScript.Shell
    $Flag=0
    Foreach($itemPath in $Path)
    {
        $itemName = Split-Path -Path $itemPath -Leaf
        #pin application to windows Start menu
        $ItemLnk = $Desktop.ParseName($itemPath)
        $ItemVerbs = $ItemLnk.Verbs()
        Foreach($ItemVerb in $ItemVerbs)
        {
            If($ItemVerb.Name.Replace("&","") -match "Pin to Start")
            {
                $ItemVerb.DoIt()
                $Flag=1
            }
        }
    }
}
PinLnk "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe"

I tried this approach as well still not pinning mycomputer to start

PS C:\WINDOWS\system32> Function PinLnk14
>> {
>>
>> $shell = new-object -com Shell.Application
>> $folder = $shell.NameSpace("shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") # ssfDRIVES
>> $ItemVerbs=$folder.Self.Verbs()
>>         Foreach($ItemVerb in $ItemVerbs)
>>         {
>>             Write-Output $ItemVerb.Name
>>             If($ItemVerb.Name.Replace("&","") -match "Pin to Start")
>>             {
>> Write-Output "TRYING TO PIN"
>>                 $ItemVerb.DoIt()
>>             }
>>         }
>>     }
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Pinlnk14
&Open
Pin to Quick access
Mana&ge
&Pin to Start
TRYING TO PIN
Map &network drive...
Dis&connect network drive...
Create &shortcut
&Delete
Rena&me
P&roperties
1 Answers
Related