Hack 22 Control Windows Explorer with Command-Line Shortcuts


Create customized Explorer views from the command line, and save your favorite views in desktop shortcuts.

I rarely open Windows Explorer in its default view. Instead, I generally want to open it at a specific location, with a specific set of viewing features?for example, with the Folders bar in the left side on or off.

I launch Windows Explorer from the command line, along with a set of switches for controlling how it opens. I also create desktop shortcuts out of these command-line launches, so that my favorite views are always only a couple of clicks away.

For example, when I want to open Windows Explorer to the C:\Power Tools Book\Hacks subfolder only, with no folders above it, and using the Folders bar, I open the command prompt and issue this command:

explorer /e,/root,c:\Power Tools Book\Hacks

When I do that, the view pictured in Figure 3-7 appears.

Figure 3-7. Opening Windows Explorer to a specific folder with a specific view

Compare that view with my default view that I get when I launch Windows Explorer the normal way (shown in Figure 3-8). Not only does the Explorer view in Figure 3-7 open to a specific subfolder, but it also shows no folders above it. In contrast, Figure 3-8 shows the entire structure of my hard disk and opens to C:\. I use the view in Figure 3-7 when I want to work exclusively on a specific subfolder and want to get to it quickly.

Figure 3-8. My default for launching Windows Explorer

This is just one of the many uses for launching Windows Explorer from the command line with switches; no doubt you'll be able to find other uses for it. You'll be able to use it not only on the command line and with desktop shortcuts, but also if you run scripts and batch programs.

The syntax for running Explorer from the command line with switches is:

explorer  [/n]  [/e] [,root,object] [[,/select],subobject]

You don't have to use switches; you can type explorer by itself, though doing that launches your default Explorer view.

Here is an explanation of how to use the switches and syntax:


Opens Windows Explorer without displaying the Folders bar, the tree structure of the hard drive. Instead, it launches the view shown in Figure 3-9.

Figure 3-9. The view of Explorer using the /n switch

Opens Windows Explorer displaying the Folders bar.

/root ,object

Opens Windows Explorer to a specific object, such as a folder, without displaying the folders above it, as shown in Figure 3-7. You can also use Global Unique Identifiers with this switch, as explained later in this hack.

[[/select] ,subobject]

Opens Windows Explorer to a specific file or folder that is then highlighted or expanded. You can use the subobject switch only without the /select parameter. When you include the /select parameter, the branches are not expanded, the folder is highlighted, and the subobject is highlighted in the right pane.

3.3.1 Create Desktop Shortcuts for Explorer

Typing command-line shortcuts can quickly give you a case of carpal tunnel syndrome, so a better idea is to run them as desktop shortcuts. Right-click on the desktop, choose New Shortcut, and in the location box type the Explorer command-line syntax you want to use. Click Next and give the shortcut a descriptive name?for example, "Hacks folder"?and click OK.

3.3.2 Using Global Unique Identifiers (GUIDs) with Command-Line Switches

You might want to open Explorer to certain system folders?for example, to My Network Places. To do so, run explorer from the command line and follow it by a space, two colons, and the Global Unique Identifiers (GUIDs) that identify specific system folders, like this:

explorer  ::{208D2C60-3AEA-1069-A2D7-08002B30309D}

That command opens Windows Explorer to My Network Places.

If you're using switches, similarly put a space and two colons in front of the GUID, like this:

explorer /e, ::{208D2C60-3AEA-1069-A2D7-08002B30309D}

You can use GUIDs in desktop shortcuts, batch files, and scripts, as well as at the command line. Table 3-1 lists the GUIDs for various system folders.

Table 3-1. GUIDs for system folders

Folder name


My Computer


My Network Places


Network Connections


Printers and Faxes


Recycle Bin


Scheduled Tasks