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_ROOT\CLSID. 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.

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.

Explorer.exe and Visual Basic.NET 2005

Putting Everything Together

Opening My Computer

'My Computer
Process.Start("explorer.exe", "/n, _
   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")

Opening Windows Explorer

'Windows Explorer
Process.Start("explorer.exe", "/n,/e,C:\")

By specifying C:\ here, Windows Explorer will open (/select) the C:\ drive automatically once opened.

Opening My Computer in Windows Explorer view

'My Computer in Windows Explorer View
Process.Start("explorer.exe", "/n, /e, _
   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")

Opening the Recycle Bin

'Recycle Bin
Process.Start("explorer.exe", "/n, _
   ::{645FF040-5081-101B-9F08-00AA002F954E}")

Opening Network Neighborhood

'Network Neighborhood
Process.Start("explorer.exe", "/n, _
   ::{208D2C60-3AEA-1069-A2D7-08002B30309D}")

Opening My Documents

'My Documents
Process.Start("explorer.exe", "/n, _
   ::{450d8fba-ad25-11d0-98a8-0800361b1103}")

Opening My Documents in Windows Explorer view

'My Documents In Windows Explorer
Process.Start("explorer.exe", "/n, /e, _
   ::{450d8fba-ad25-11d0-98a8-0800361b1103}")

By specifying /e, you display the My Documents folder in the Windows Explorer view.

Opening the Default Internet Browser

'Default Browser
Process.Start("explorer.exe", "/n, _
   ::{871C5380-42A0-1069-A2EA-08002B30309D}")

This should open the default Internet browser.

Opening the Control Panel

'Control Panel
Process.Start("explorer.exe", "/n, _
   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ _
   ::{21EC2020-3AEA-1069-A2DD-08002B30309D}")

This is where it may get tricky. If you look closely at the above statement, you will notice that it references the CLSID of My Computer and then another CLSID at the back. This is because the Contol Panel is a subobject of My Computer; that is why you will notice the backslash separating the two. Think of it as an ordinary path. Imagine opening My Computer by double-clicking on it, and then selecting Control Panel from within the My Computer window.

Opening Printers and Faxes

'Printers And Faxes
Process.Start("explorer.exe", "/n, _
   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ _
   ::{2227A280-3AEA-1069-A2DE-08002B30309D}")

This statement works basically the same as the statement opening the Control Panel. This time, however, you reference the Printers and Faxes' CLSID in conjunction with My Computer's CLSID.

Opening Scanners & Cameras

'Scanners & Cameras
Process.Start("explorer.exe", "/n, _
   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ _
   ::{21EC2020-3AEA-1069-A2DD-08002B30309D}\ _
   ::{E211B736-43FD-11D1-9EFB-0000F8757FCD}")

Now it gets even worse, LOL! Not really. Remember the path scenario I spoke about earlier? This is the same. The above statement can be translated to:

My Computer \ Control Panel \ Scanners and Cameras

Scanners and Cameras is one of your Control Panel items in My Computer.

Opening Fonts

'Fonts
Process.Start("explorer.exe", "/n, _
   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ _
   ::{21EC2020-3AEA-1069-A2DD-08002B30309D}\ _
   ::{D20EA4E1-3957-11d2-A40B-0C5020524152}")

My Computer \ Control Panel \ Fonts

Opening Web Folders

'Web Folders
Process.Start("explorer.exe", "/n, _
   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ _
   ::{BDEADF00-C265-11D0-BCED-00A0C90AB50F}")

Opens the Web Folders folder.

Opening Tasks

'Tasks Scheduler
Process.Start("explorer.exe", "/n, _
   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ _
   ::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}")

Opens Task Scheduler.

Opening Admin Tools

'Administration Tools
Process.Start("explorer.exe", "/n, _
   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ _
   ::{21EC2020-3AEA-1069-A2DD-08002B30309D}\ _
   ::{D20EA4E1-3957-11d2-A40B-0C5020524153}")

Opens the Administrative Tools.

Opening Files Search results

'Results Of Search
Process.Start("explorer.exe", "/n, _
   ::{1F4DE370-D627-11D1-BA4F-00A0C91EEDBA}")

This will open the Windows Search Results window.

Conclusion

I hope that you have enjoyed reading this article, and most importantly, that you now understand how explorer.exe works, and how you can utilise its power in your applications.



About the Author

Hannes du Preez

Hannes du Preez is a Microsoft MVP for Visual Basic. He is a trainer at a South African-based company. He is the co-founder of hmsmp.co.za, a community for South African developers.

Downloads

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds