Customize Your Shortcuts to Folders (Windows)

In Windows, you can create a shortcut to a folder (for example, by right-click and dragging the folder from the Windows Explorer onto the desktop and selecting “create shortcut here”). Then, when you double-click on the shortcut, Explorer opens back up and displays the contents of that folder. There are four default characteristics when this happens:

  1. It will open a single pane window (no Explorer bar).
  2. It will allow the user to navigate out of the folder (i.e. to the folder’s parent and beyond).
  3. The default is for none of the items in a folder to yet be selected.
  4. If there is already an open Explorer window displaying that folder, then the operating system will switch to that existing view, as opposed to opening a new one.

All of these behaviors can be customized.

The first step is to convert the shortcut target from implicitly invoking the Explorer to explicitly invoking it. If you examine the properties of a folder shortcut, as described above (right-click and select Properties), you’d see that the Target field is the name of the folder.

folder_shortcut.jpg

Normally, for a Windows shortcut, the target is the name of a program to execute, but in this case it is just a folder name. When Windows sees that it is just a folder name, it assumes that you really want to open the Explorer, passing it the name of that folder. In other words, having a target of just “SomeFolder” is the equivalent of a target that says “%windir%\explorer.exe SomeFolder”. (The “%windir%” is automatically replaced with wherever Windows is installed.) So, click inside the target field and paste “%windir%\explorer.exe ” (without the quotes, but with the trailing space) in front of the folder name.

The next step is to add certain “command-line switches” that Windows Explorer understands. These switches are as follows:

  • /n forces it to open a new window, even if it duplicates a window that is already open.
  • /e uses Windows Explorer view (multi-paned).
  • /root,X restricts Explorer to showing only the contents of file folder X (and its sub-folders).
  • /select,Y automatically selects Y (either a file or folder).

These switches can be used in any combination, in any order. To use multiple switches, separate them with commas (but no spaces). for example, a target of “%windir%\explorer.exe /n,/e,c:\temp\demo” tells Explorer to open a new window to show the contents of C:\temp\demo, even if there is already a window open on that folder, and to make the Explorer bar visible. The next example uses all four switches:

/n,/e,/root,c:temp,/select,c:temp\demo\quick.txt

Note: The /root switch has no effect if the user has admin privileges.


Update: I forgot to mention that Exporer is quite unusual with respect to how the commmand line arguments are separated by commas. Usually, they are separated by spaces. And if a single argument contains spaces, then normally it would have to be enclosed in quotes, but that is not required here (which is undoubtedly why the Explorer programmers elected to use commas).

Trackbacks & Pings

Comments

  1. This is very cool. I think your example in the blue box needs a backslashes after the “c:”. (visiting from Lifehacker)

  2. How does this affect the type of window explorer opens? Explanation: I’ve noticed that an Explorer window (Win-E shortcut) never gives the “View -> Filmstrip” option whereas a Folder window (Start -> My Computer/My Documents/…) will give that option. Is that what the /e does? I don’t have a winXP machine handy to test this right now.

  3. Sounds like an interesting idea, although these examples appear quite limited in their application. Are there any other “command-line switches” you could use? Could you, for instance, open multiple files, or move files? I guess we are talking about DOS prompts or something like that, but it isn’t really something I know anything about.

    Thanks anyway for an interesting post.

    Joe
    http://www.gadgettutorials.com/

  4. Good introduction to making shortcuts. Kind of just a copy of (http://support.microsoft.com/kb/130510) but still, easy to follow and usefull :)

  5. that was really cool! saves a lot of clicks!

  6. Samantha: Thanks. Somehow the PRE formatting conflicted with the backslashes in that last example. I had to drop the blue highlighting but the backslashes are back.

    Harvey: Sorry, I don’t know why the film strip option would show up one way but not the other. I don’t imagine that the /e switch would have anything to do with it.

    Joe: Sorry, but those are the only 4 switches that Explorer understands, that I’m aware of. Yeah, as far as automating the movement of files that would be a job for a DOS batch file (or a shell script running under CygWin). If you provide me with an example of the kinds of files that need to be moved frequently, I would be happy to write up how to do it.

    Neon & meki: Thanks. I’m glad this helps.

  7. Great to know, thanks.

    Keep in mind, though, that if you use shortcuts as a way to drop files to that directory, it will no longer work. We use shortcuts for workflow stages (an Archive shortcut in our client folder, for example), that moves the files to a new location.

  8. nick: Oh, right, because now the shortcut is a representation of the Explorer program (with arguments that specify the folder), rather than being a representation of the folder itself. So, dragging and dropping onto the shortcut now means sending the object to Explorer, rather than sending it to the folder. Good catch.

  9. This is a little off-topic, but has to do with Explorer. Is it possible to specify that by default all instances / windows of Explorer use the ‘/e’ switch. So instead of changing all of my shortcuts, every time I open a folder it shows me the multi-pane view?

  10. I like the way you set up that your info is the homepage, nicely done. Thanks!

  11. I have a shortcut to a folder (I didn’t set it up) and I would like to delete it. Everytime I do though, it just comes back the next time I boot up. It shows up in the directory
    right after Desktop, before My PC. Need an
    exterminator-JYK

  12. Julius: It sounds like there is a BAT file or a program that is re-creating it as part of your start-up sequence. That’s a non-standard approach, but I can easily see some rogue program doing such a thing, and I can easily imagine whoever programmed the uninstaller forgetting about that auto-create process and leaving it behind. — Oh, wait. Is this one of the system folders? Like “My Photos”? There are settings available through TweakUI that control those. We wrote about TweakUI recently on CodeJacked.

  13. Thanks for the info here – I actually used it to build a workaround for a very slow loading Windows Explorer folder / directory by setting up a shortcut to the folder in XYPlorer with the syntax: “C:\Program Files\XYPLORER\XYplorer.exe” W:\Folder

    For whatever reason Windows was choking on this directory (it is fairly large) but none of the fixes I could find online would address the 10-15 second load delay. XYPlorer doesn’t have the problem so it’s a reasonable fix – plus I like the added functionality of XYPlorer.

    http://www.pricelesswarehome.org/2006/PL2006FILEUTILITIES.php#FileManager

  14. Does anyone know how to create a shortcut to search a specific folder for all files and folders?

  15. Thanks a bunch. It is NOT the same as the microsoft post, and is much easier to find. After several hours of searching I found this. Good stuff, really well written.

  16. any way to sort the opened folder by date modified? I’m using Windows 8.

  17. certainly like your web-site however you have to take a look
    at the spelling on several of your posts. Many of them are rife
    with spelling problems and I find it very bothersome to tell the truth nevertheless I will surely come again again.

Post a Comment


Your email is never published nor shared. Required fields are marked *



© 2006-2007 Maxim Software Corp.  All rights reserved.