2

I am trying to pin a program to the start menu in Windows 10

$shell = New-Object -ComObject "Shell.Application"
$Folder = $shell.NameSpace("C:\Test")
$exe = $Folder.ParseName("notepad.exe")
#$exe.Verbs()
$ItemVerbs = $exe.Verbs()

Foreach($ItemVerb in $ItemVerbs)
{
    If($ItemVerb.Name.Replace("&","") -match "Pin to Start")
    {
       $ItemVerb.DoIt()

       Write-Host "Pin to the Start menu sucessfully.+ ""$ItermVerbTxt"" " -ForegroundColor Green
     }
}

After executing this code, i see the success message which means it is finding the required verb.

But i DONT see notepad.exe tile in Start Menu.

Please help

chaitug
  • 21
  • 1
  • 1
  • 2

2 Answers2

1
function Pin-App {
    param(
        [string]$appname,
        [switch]$unpin
    )
    try {
        if ($unpin.IsPresent) {
            ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ? { $_.Name -eq $appname }).Verbs() | ? { $_.Name.replace('&', '') -match 'From "Start" UnPin|Unpin from Start' } | % { $_.DoIt() }
            return "App '$appname' unpinned from Start"
        }
        else {
            ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ? { $_.Name -eq $appname }).Verbs() | ? { $_.Name.replace('&', '') -match 'To "Start" Pin|Pin to Start' } | % { $_.DoIt() }
            return "App '$appname' pinned to Start"
        }
    }
    catch {
        Write-Error "Error Pinning/Unpinning App! (App-Name correct?)"
    }
}

Pin-App "Outlook 2016"
Pin-App "Google Chrome" 
Pin-App "This PC"
Grilse
  • 3,491
  • 2
  • 28
  • 35
K.Nickson
  • 19
  • 2
  • Your `$unpin.IsPresent` is always False so it will never actually unpin an app from Start. You should add `-unpin` like: `Pin-App "..." -unpin` – Dieter Feb 20 '18 at 08:08
  • This solution doesn't work on Windows Version 1903. I was really hopeful it would work. – MKANET Mar 10 '21 at 22:43
0

This is no longer possible in Windows 10 (latest seemed to work in 8.1). I can not say for sure, but these issues seem to be linked. Please see here:
https://connect.microsoft.com/PowerShell/feedback/details/1609288/pin-to-taskbar-no-longer-working-in-windows-10
and also here:
Pin program to taskbar using PS in Windows 10.

Community
  • 1
  • 1
Janis S.
  • 2,526
  • 22
  • 32
  • 2
    The links you have provided talks about pinning to "taskbar". I am looking for pinning to "Start menu" as a tile. I totally agree that we cannot pin to "taskbar" and i dont see a verb for this on Win10. Where as i see "Pin to Start" verb when i query on Win10 machine, but code is not actually pinning to start menu – chaitug Apr 22 '16 at 12:16
  • You are right. I could not find any official prove, however, people has tried this unsuccessfully http://www.osd-couture.com/2015/07/windows-10-pin-to-start-is-back.html – Janis S. Apr 22 '16 at 12:42
  • Also here: http://stackoverflow.com/questions/32359910/windows10-script-pin-app-to-start-menu – Janis S. Apr 22 '16 at 12:49