3

In Windows 7 is there a way to add a location to the Explorer Favorites navigation pane from the command line? I'm working with systems that are frequently re-imaged, and I would like to automate adding a number of favorite folders to explorer.

I imagine these favorites are also stored in the registry. If someone knows where, I could probably automate managing them through the reg command, although this is less than ideal. I've looked at a number of locations related to explorer suggested here, but haven't found them yet.

For information on customizing the favorites section of the navigation pane with Explorer, see http://www.howtogeek.com/howto/10357/add-your-own-folders-to-favorites-in-windows-7/

3 Answers 3

3

They are stored in each user's profile under %USERPROFILE%\Links.

From the Start search, or Run dialog, or in Explorer (etc.) you can also get there by typing shell:links.

4
  • Wow, didn't think it would be that easy :) Any way to order the links? Commented Sep 12, 2012 at 3:16
  • This answer doesn't mention anything about setting up favourites via the command line. Commented Sep 14, 2013 at 18:10
  • @aaronjbaptiste You create a regular link/shortcut to the location you'd like, and then copy it to that folder. Commented Sep 14, 2013 at 18:24
  • @techie007 But what's the command to create a shortcut via the command line? I'm currently using a tool called xxmklink, but AFAIK there is no native way to do this. Commented Sep 16, 2013 at 7:27
1

AFAIK there is no native method to create a shortcut via the command line (and the Favourites here cannot be a symlink, they must be a shortcut). You can do it using xxmklink:

XXMKLINK.EXE "%userprofile%\Links\Dropbox.lnk" "C:\Dropbox"

Would create a windows Explorer Favourite to C:\Dropbox

1

I believe this answers the question.

I made a function from that post. It might come in handy for someone:

Function New-Shortcut {
Param(
    [Parameter(mandatory=$true)]$TargetPath,
    [Parameter(mandatory=$true)]$Name
)
    $WshShell = New-Object -comObject WScript.Shell
    $Shortcut = $WshShell.CreateShortcut("$env:USERPROFILE\Links\$Name.lnk")
    $Shortcut.TargetPath = $TargetPath
    $Shortcut.Save()
}
2
  • While this does create a link. The link lacks an icon, name and type. I used the above script to create a shortcut to a directory. When it's clicked on, it presents a "Choose the program you want to use to open the file" dialog. Commented Oct 27, 2015 at 16:04
  • I tested the function again and cant see any issues here. The icon depends on what you're creating a shortcut to, in this case it's the default directory icon. The name will be whatever you specify.. Considering you get the "Choose the program you want to use to open the file" dialog - are you sure your path is correct? I used this exact command: New-Shortcut -TargetPath "c:\temp\" -Name "TMP" Commented Nov 24, 2015 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .