Explorer.exe and Visual Basic.NET 2005

Explorer.exe and Visual Basic.NET 2005

As many of you know, explorer.exe is the Windows Program Manager or Windows Explorer. It manages the Windows Graphical Shell including the Start menu, taskbar, desktop, and File Manager. For example, if you were to open My Computer from your desktop, explorer.exe runs; if you were to open the Recycle Bin, explorer.exe runs again. In this article, I will explain how to launch the main desktop icons, some Control panel items, and more with explorer.exe and Visual Basic.NET 2005.

First, the Complicated Stuff

CLSID explained

A Class ID (CLSID) is a 128-bit (large) number that represents a unique ID for a software application or application component. Typically, the IDs are displayed like this: “{645FF040-5081-101B-9F08-00AA002F954E}”. You can think of a CLSID as a social security number or Identification number for a piece of software, or a software component.

Windows uses CLSIDs to identify software components without having to know their names. They also can be used by software applications to identify a computer, file, or other item.

Why am I talking about CLSIDs?

The answer is simple. To execute/start the appropriate desktop or Control Panel item, with explorer.exe, you would need to specify the CLSID of the appropriate item so that explorer.exe knows which item you are launching.

OK, but where are these CLSIDs stored?

All CLSIDs are stored in the Registry, usually at HKEY_CLASSES_ROOTCLSID. 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_MACHINESOFTWAREMicrosoftWindows CurrentVersionExplorerControlPanelNameSpace where you can find all CLSIDs related to the Control Panel.

Explorer.exe Explained

As mentioned earlier, explorer.exe is the Windows Program Manager, or Windows Explorer. It manages the Windows Graphical Shell including the Start menu, taskbar, desktop, and File Manager. For example, if you were to open My Computer from your desktop, explorer.exe runs; if you were to open the Recycle Bin, explorer.exe run again.

explorer.exe can be broken down into the following parts:

explorer [/n] [/e][,/root,object][[,/select],subobject]
Parameter Explanation
/n Always opens a new window (even if the specified folder is already open).
/e Uses Windows Explorer view. The default is Open view.
/root, object Specifies the object in the normal name space that will be used as the root of this Windows Explorer Folder. The default is to just use the normal name space root (the desktop).
/select Specifies that the parent folder is opened and the specified object is selected.
subobject Specifies the folder to receive the initial focus unless /select is used. The default is the root.

These parameters allow you to pass additional information to explorer.exe on how to function. For example, they tell you what to open, and in which view/mode to open them.

Example

Say, for example, I want to open the My computer icon through explorer.exe. You have already established that you need to specify a CLSID to open, and as explained in the previous section, you have established that you need to pass certain parameters to explorer.exe as well.

To open My Computer, you can do the following:

  1. Click the Start Button on the Windows Start Menu.
  2. Select Run.
  3. Enter the following:
  4. explorer.exe /n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
  5. Click OK.

The above code will open the My Computer icon (with a CLSID of {20D04FE0-3AEA-1069-A2D8-08002B30309D}) in a new window (/n).

Here’s another example:

  1. Click the Start Button on the Windows Start Menu.
  2. Select Run.
  3. Enter the following:
  4. explorer.exe /n, /e,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
  5. Click OK.

The above code will open the My Computer icon (with a CLSID of {20D04FE0-3AEA-1069-A2D8-08002B30309D} ) in a new window (/n), in Windows Explorer View. In other words, it will give you the Folder & Drive Pane on the left side as well the the Files pane on the right side (/e).

Running explorer.exe from Visual Basic.NET 2005

To run explorer.exe with or without additional parameters, you will need to use the Process class. This class provides access to local and remote processes and enables you to start and stop local system processes.

A Process object provides access to a process that is running on a computer. A process, in the simplest terms, is a running application. A thread is the basic unit to which the operating system allocates processor time.

To start a Process, you can use the Start method from the Process class; you also can include the StartInfo parameter that members can use to duplicate the functionality of the Run dialog box of the Windows Start menu. Anything that can be typed into a command line can be started by setting the appropriate values in the StartInfo property. The only StartInfo property that must be set is the FileName property. The FileName property does not have to be an executable file. It can be of any file type for which the extension has been associated with an application that is installed on the system. For example, the FileName property can have a .txt extension if you have associated text files with an editor, such as Notepad, or it can have a .doc extension if you have associated .doc files with a word processing tool, such as Microsoft Word.

In the command line, you can specify actions to take for certain types of files. For example, you can print documents or edit text files. Specify these actions using the Verb member of the StartInfo property. For other types of files, you can specify command line arguments when you start the file from the Run dialog box. For example, you can pass a URL as an argument if you specify your browser as the FileName. These arguments can be specified in the StartInfo property’s Arguments member.

More by Author

Must Read