Is it possible programmatically add folders to the Windows 10 Quick Access panel in the explorer window?

前端 未结 9 861
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 12:18

Apparently Microsoft has (sort of) replaced the \"Favorites\" Windows explorer item with the Quick Access item. But I haven\'t been able to find a way to programmatically ad

相关标签:
9条回答
  • 2020-11-28 12:42

    I got an answer here:

    Windows 10 - Programmatically use Quick Access

    Apparently, it's not possible yet, but a proposition for such an API has been made.

    0 讨论(0)
  • 2020-11-28 12:47

    There is a simple way to do it in powershell (at least) :

    $o = new-object -com shell.application
    $o.Namespace('c:\My Folder').Self.InvokeVerb("pintohome")
    

    Hope it helps.

    0 讨论(0)
  • 2020-11-28 12:48

    EDIT: After further investigation, I have realized Quick Access contains two "sections". One is Pinned Items, and the other is Frequent Folders. For some reason, Music and Videos come by default on the second section (at least in 1909), unlike the rest (Desktop/Downloads/Documents/Pictures). So the verb to invoke changes from unpinfromhome to removefromhome (defined in HKEY_CLASSES_ROOT\FrequentPlace, CLSID: {b918dbc4-162c-43e5-85bf-19059a776e9e}). In PowerShell:

    $Unpin = @("$env:USERPROFILE\Videos","$env:USERPROFILE\Music")
    $qa = New-Object -ComObject shell.application
    $ob = $qa.Namespace('shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}').Items() | ? {$_.Path -in $Unpin}
    $ob.InvokeVerb('removefromhome')
    

    In Windows 1909, you can't unpin the Music or Videos links from Quick Access with the proposed PowerShell solution. It seems they're special because they don't include the "pin" icon, unlike the rest.

    The solution is to pin and unpin them. I don't know much about the Windows API or PowerShell so there may be a less convoluted way.

    $Unpin = @("$env:USERPROFILE\Videos","$env:USERPROFILE\Music")
    $qa = New-Object -ComObject shell.application
    ForEach ($dir in $Unpin) { $qa.Namespace($dir).Self.InvokeVerb('pintohome') }
    $ob = $qa.Namespace('shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}').Items() | ? {$_.Path -in $Unpin}
    $ob.InvokeVerb('unpinfromhome')
    

    Another way is renaming f01b4d95cf55d32a.automaticDestinations-ms, then logging off/rebooting so that it's recreated. But I don't know if it has side effects. Batch script:

    :: f01b4d95cf55d32a => Frequent Folders
    :: 5f7b5f1e01b83767 => Recent Files
    rename "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations\f01b4d95cf55d32a.automaticDestinations-ms" f01b4d95cf55d32a.automaticDestinations-ms.bak
    
    0 讨论(0)
提交回复
热议问题