Pin program to start menu using PS in Windows 10

前端 未结 2 1980
后悔当初
后悔当初 2021-01-15 13:03

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\")
$e         


        
相关标签:
2条回答
  • 2021-01-15 13:37

    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.

    0 讨论(0)
  • 2021-01-15 13:54
    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"
    
    0 讨论(0)
提交回复
热议问题