How to display Windows Explorer objects in one command-line

This article shows how to display Windows desktop objects like Control Panel, Administration Tools, Scanners and Cameras etc., in one command-line, and provides a complete application for illustration.

Introduction

All Windows versions have a default shell consisting of one main program, Explorer.exe, launched by the Winlogon process each time an interactive session is opened. The shell for the Windows 9X family is stored in the win.ini file in the [boot] section as the value of the shell key. In the Windows NT family (NT4/2K/XP/2003), the shell value is stored in the registry. The Winlogon process begins by retrieving the shell data value in the registry key: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon. If it does not exist in this last key, it looks for it in the key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon as indicated below.

In this article, we are interested in the Microsoft default shell (Explorer) objects, precisely in, how we can launch multiple Explorer system and special folders (My Computer, My documents, Recycle Bin, Control Panel, Network Neighbourhood etc.) and panes in one command-line without any code. Technically speaking, all these standard objects represent objects belonging to namespaces handled by the Windows Explorer graphical interface. Since the Explorer also takes into account the namespace extensions, the examples given in this article should apply to the objects belonging to these extensions.

How to use Explorer to show special objects

The Windows Shell program, Explorer.exe, is stored in the Windows folder, obtained through the environment variable WinDir. Usually, this folder is a part of the PATH environment variable. And as a consequence, we don't need to specify the whole path to Explorer.exe when calling this program.

The table below summarizes some of the command-line parameters passed to Explorer and the result of the execution. Note that all the examples given in this table have been tested only on the Windows XP platform. There is no reason that these examples will not work on at least NT-platforms (NT4/2K/XP/2003). The general Explorer command-line syntax is well known, and can be found on many Internet sites (see for example, the Q130510 article on the Microsoft site). But, the article's main contribution consists in showing how to specify some parameters (X, Y)=(object, sub-object) (see next section) to show special objects like My Computer, My Documents, Control Panel etc. Some of these objects are available in the Start Menu of the tasks bar (one of the graphical parts of the Explorer). To try the examples below, just open a console (cmd or command depending on your OS) and copy/paste each example. If you want to play with them, I have provided two complete and very small applications coded in Visual C++ 6 and Visual Basic 6. Some details of these applications are given below in the next sections.

Explore what?

Command-line

Object X and optionally sub-object Y (general case)

General syntax:

Explorer [/n][/e][,/root],X,[[/Select],Y]

Notes:

Use /e to show the left Explorer pane (TreeView) together with the right pane (ListView).

Use /n to hide the left Explorer pane (TreeView).

If /root is present, we start exploring at the root object (X) and objects belonging to X.

If /root is not present, we explore the object X, its children, and other Explorer objects as well.

Examples:

Exploring drive C: only with Folders panel and then without it:

Explorer /E,/Root,C:

Explorer /Root,%SystemDrive%

Exploring Windows directory only:

Explorer /E,/Root,%windir%

Exploring the Logon Server (you can use UNC paths) only:

Explorer /E,/Root,%LogonServer%

Exploring the current user profile path only:

Explorer /E,/Root,%HOMEDRIVE%%HOMEPATH%

Exploring the System32 folder and putting the focus on the calc.exe program:

Explorer /N,%windir%\system32,/select,%windir%\system32\calc.exe

My Computer

Explorer /E,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

Explanation: The object My Computer is a namespace which has the CLSID: {20D04FE0-3AEA-1069-A2D8-08002B30309D}

Where the CLSIDs of special Explorer objects can be found?

There are many ways to find the CLSIDs referenced in the examples given in the previous section. Three methods are given below:

The first place to look for is the registry in the hive: HKEY_CLASSES_ROOT\CLSID, for example. Some of the special CLSIDS can also be found in the registry keys where the related namespace extensions are specified as in the key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\ CurrentVersion\Explorer\ControlPanel\NameSpace\ where you can find all CLSIDs related to the Control Panel.

The second place to look for, is the OS shell resources DLL shell32.dll. To find the CLSIDs, you have to follow these steps:

Step 1: Launch VS6, for example.

Step 2: Click on the menu File-Open, and select file type: Executable Files, Open as: Resources, and then select the file shell32.dll, which is found in the System32 system folder (if the DLL is locked, you have to make a copy of it elsewhere and open it from the new place):

Step 3: Open the custom resources "REGINST" as indicated in the figure below. Open this resource, and you will find all default CLSIDs installed on your OS. In fact, this file has the INF file format, and the CLSIDs can be found in the [Strings] section. All CLSIDs are prefixed by CLSID_.

Note that you can also use public tools more appropriated to edit resources like: Resource Hacker by Angus Johnson.

The third place, is the Windows CD setup in the i386 folder in a INF file used during the installation process. If you have a Windows XP CD setup, you can find these CLSIDs in the HIVECLS.INF file.

Application 1

The application is a MFC Dialog application whose UI is illustrated at the top of this article. The design-time UI is illustrated below:

To test this application, you have to do three things:

Choose in the list, one of the objects.

Optionally, choose one of the two options or both of them.

Click on the button " GO TO -->!" in order to display the appropriate object.

The main procedure responsible for displaying the chosen object in the combo-box list corresponding to the click on the button labeled "GO TO -->!" is given below, and doesn't need any explanation for people comfortable with Microsoft C++:

Application 2

The second application is a VB 6 example using Internet Explorer Control whose UI is illustrated as the second figure at the top of this article. I want in this application to give another approach using Explorer objects different from the one used in VC++ sample application. The code is quite simple and makes use of one call to the Windows API GetClientRect declared as:

in order to resize the form. Note that in VB objects, dimensions are measured in Twips units, and since this API returns the window client rectangle in Pixels units, we have to convert these dimensions to Twips by using the Screen object properties : TwipsPerPixelX and TwipsPerPixelY (see the event Form_Resize() content). In order to display the Explorer objects, I have used the Internet Explorer method Naviagte2 with no optional parameters in the event handler cboObjects_Click(). The complete code is given below:

Points of interest

This article has shown us how to launch Windows Explorer objects that are not ordinary ones like folders or files. The examples given here can be used in any code source whatever the programming or the script language used is, as long as it is used in the Windows platform.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

The key here is the line containing TargetPath property. In order to create shortcut to any system object, you have just to replace from this article the appropriate path (see section How to use Explorer to show special objects, addressed table.

After creating the shorcut on the desktop, right-clic the shorcut icon and ask for properties. Note that the created shorcut has the appropriate icon and the appropriate Target name (not a file).

You can do the same thing in other languages like C++, Delphi, JavaScript etc.

If you read the article well it is quite known that the syntax of the use of the Explorer.exe program is well-known: [130510] and that the principal contribution of the article is to be able to explore all the Desktop objects.

If you think that the article is useless, can you indicate to me how to display these various objects by using only Explorer.exe (in one command-line) and without using neither ShelExecute(Ex) neither the CLSID indicated in the article nor other API or advanced script language?

Hmm!
I hate windows , I'd juste like/want/need to use a better product/idea/concept.
Unfortunately I still wait and use it, and better than anything else.

I'll not answer any reply, it's not a forum for that, I'd just like to give my strong support to people like John11 that help others digging this monstreous collection of API that always contains what you need, but where!

In fact, the VB sample presents another approach different from that of the VC++ sample. It uses the Internet Explorer Browser (we can use in-place automation). And as a consequence, we display the Explorer objects in the application window not outside as in the VC++ application.;)