Custom Search

Saturday, November 17, 2007

Using Windows Explorer's Command-Line Syntax

Cascading folder menus, as described earlier in this chapter, are one way to open Windows Explorer with a particular folder in view. But they might not be the ideal way. Compare the two views of the System32 folder. The one on the left was generated by a Start menu item; the one on the right was produced by means of Windows Explorer's command-line syntax.

The view on the right, produced by a command string, restricts the Folders bar to a particular branch of the file structure.

The difference between the two is all in the Folders bar. The command-line string in this case puts the selected folder (System32) at the top of the folder hierarchy, eliminating all folders at higher levels and letting you focus your attention on System32.

This is one example of the usefulness of the Windows Explorer command-line syntax. You can probably find others in your own work. You can use Windows Explorer command strings in shortcuts, with the Start menu's Run command, at the command prompt, or in batch programs or scripts. The syntax is as follows: explorer [/n /e][,/root,object][[,/select],subobject]
The switches, all of which are optional, have the following effects:

Switch Effect
/N Opens without displaying the Folders bar.
/E Opens with the Folders bar displayed.
/Root,object Restricts Windows Explorer to object and all folders contained within object.
/Select,subobject Gives the initial focus to the parent folder of subobject and selects subobject. If /Select is omitted, subobject specifies the folder that gets the initial focus.

Let's look at some examples. To begin, explorer /e,/root,%systemroot%\system32
opens Windows Explorer and displays the Folders bar, restricting the namespace to %SystemRoot%\System32 and its subfolders.
To open %SystemRoot%\Cursors in Windows Explorer, with the Folders bar displayed and the file Appstart.ini selected, you must include the file name and extension in the command string, as follows: explorer /e, /select,%systemroot%\cursors\appstart.ani

Typing the following opens %SystemRoot% without the Folders bar: explorer %systemroot%
The folder is loaded as the subobject focus, not as the root folder-which means that you can navigate upward from %SystemRoot% in the folder hierarchy.

The string

explorer /n

opens the drive on which Windows XP is installed without displaying the Folders bar, whereas explorer /e,.

opens %UserProfile% and displays the Folders bar.

0 comments: