Associated: A Windows Shell Extension

Necessity is indeed the mother of invention. Most things you see around you in life are there because somebody one day had a need that the current crop of available tools could not satisfy. Seeing the need, a tool maker then created (and eventually refined) a tool so everybody could get the job done. Of course, one of the really cool things about being a tool maker is that you never have to wait for somebody else to solve your problem.

My “necessity” began with VMware. I tend to use this software often, and I have many associated virtual machines that I maintain. From its GUI, the software provides a menu (called “Windows”) that lists all the recent VMs that you have run. However, the menu seems to be limited to about 10 entries. In addition, in the version I’m using, when you hit that limit, instead of dropping some unused entry to make room, it seems to just forget the VM the next time you run the application instead of adding it to the menu. These two shortcomings alone are enough to drive me crazy, and so came the inspiration for Associated.

[ An Improved MRU List ]

Such menus as VMware’s “Windows” are called MRUs, which stands for “Most Recently Used”. While they are dynamic, adding entries implicitly, they can lack some nicer — or even some sane — features. So, I decided to create an MRU that could be applied to any program that I have installed, not just one that would address the shortcomings in VMware’s interface. To do this, I have created a Windows Shell Extension. A Shell Extension is designed to extend the functionality of the Windows Shell (i.e., Explorer). By utilizing this, I can create MRU functionality that can be provided to any application.

As the name implies, Associated is a Windows Shell Extension that adds a context menu entry that will maintain a list of “associated” elements for any given application. In terms of VMware, this would be a list of associated virtual machines much like that provided by the “Windows” menu within the application. However, as a Shell Extension, I don’t even need to run the application before I select a VM to run from a list. The same can be applied to other applications.

The drawback to this approach, however, is that you must explicitly add entries to your MRU for each application (whereas, within the context of the running application, such features can be implicit). I’ve tried to make this task as easy as possible, and have added some value to the Associated MRU that most application-based MRUs don’t offer.

[ Install The Extension ]

Download the installer for the extension that matches your Windows flavor (32-bit or 64-bit):

Associated requires at least Windows Vista.

After you’ve installed the extension, your Windows context menu will have a new entry when you right-click on an executable file (or a link object that represents one):

New Context Menu Entry

This entry is your new Associated MRU menu. It will present a varying list of associated documents, depending upon the file/link context selected. Of course, immediately after installation, you’ll have yet to add any associations to the database, so your Associated sub-menu will contain only common actions.

Common Menu Actions

The most important of these common actions is the “Settings” action.

[ Filling Your Database ]

You can open the settings for Associated by selecting it from the context menu (or by running it from the Start Menu entry for Associated). When opened for the first time, it will be pretty sparse:

The Settings Window

Everything in the settings dialog is managed from context menus. Right-clicking on the blank area of the list will give you the option to add a new application to the database:

The Settings Context Menu

You can then use the file-selection dialog to navigate to the application you wish to add, and then select it. As an example, I use the “vmrun.exe” application provided with VMware to launch my virtual machines, so I locate that and select it:

Selecting An Application

This adds the first entry to the Associated database:

Our First Application

Alternatively, you can quickly add new entries to the database from the context menu. If you select an application that is not already registered, you are given the option to do so by the Associated context menu:

Registering From The Menu

This will open the Settings dialog with the application already added and ready to be configured.

By itself, the application entry will do us little good. We must now add a list of associated files to this application. However, before doing so, we might want to edit default settings for this entry.

[ Adding Some Defaults ]

Right-clicking on the application entry provides a context menu where “Edit Defaults” can be selected:

Editing Defaults

Default settings allow us to apply values to each associated entry as we add them, to cut down on the amount of typing needed. In the case of my virtual machines, I want to select a folder where they reside (they needn’t all reside there, but in my case, they do), so that each time I add a new association for “vmrun.exe”, it will start me off in that folder.

Additionally, I can add common “Options” that will be filled in for each association (described in more detail later):

Editing Defaults

With some default values established, we can start adding associations for this application.

[ Adding Associations ]

Select “Add Association” from the application context menu to start selecting associations for your new entry.

Adding An Association

This will give you a file-selection dialog box. If you set a path in the defaults for this application entry, then the dialog box should start you in that location (otherwise, it will place you back in the last location where you selected a file). For my example, I navigate to the folder that contains a VM that I want to add as an association, and select it:

Selecting An Association

This then opens a settings dialog (identical to the “Defaults” for the application) where you can edit information about the association. If you have defaults set for “Name” and/or “Options”, those fields will be filled in automatically. If not, then the base name of the file will be used as the name.

Association Settings

When you are happy with the settings, press “Ok” to add the association to your application entry:

A Completed Association

Once you’ve pressed “Ok” on the Settings dialog, the database will be updated, and you will now have an association available to your application when you right-click on it within the Shell:

Testing Your Association

[ Popularity ]

When your MRU list only contains two or three entries, those entries are all quickly accessible, no matter how often you select them. However, as an MRU list gets rather large, it can be handy to have those entries that are used more frequently than the rest filter to the top so they are the quickest to access and launch. This mechanism is known as “popularity sorting,” or “popularity filtering”.

Associated provides this type of quick-selection mechanism. For example, I’ve completely populated my list of associated VMs, giving me a list of 16 entries:

A Populated List

Notice in the image above that most entries have a popularity rating of zero. There are four entries, however, that have popularity values greater than zero. This represents the number of times those entries have been selected for launching from the Shell context menu. With popularity enabled on the application, context menu entries are presented in descending popularity order.

For example, this same list (shown above in the order they were added) would appear like this on the context menu when popularity is enabled:

Popularity List

You can disable popularity sorting, and the order presented on the context menu will exactly match the order in the settings dialog. In addition, you can reset an individual entry’s popularity rating to zero, or you can reset to zero the entire popularity rating of an application’s association list.

Of course, there are also times when you might not want popularity sorting on your list. For example, Visual Studio uses popularity sorting for its “Recent Projects” list (available on the “Start Page”). This would be a case where I would not want popularity sorting enabled, because I like to keep related solutions grouped together. Since this is a behavior I cannot control from within Visual Studio, I can of course control it from the Associated context menu:

Popularity Turned Off

So, no matter how many times I select entries from this menu, they will always remain in this order on the context menu for Visual Studio. Take that, Microsoft!

[ Constructing Options ]

As shown in the “Edit Defaults” image, the “Options” entry can have some odd-looking tokens. These letter tokens represent specific elements of specific values, and are used as placeholders for these values. Each letter token is signaled with a dollar sight (“$”) and is surrounded by a pair of braces (“{}”).

Each letter represents an element of a path, where lower-case letters refer to the path to the associated file, and upper-case letters refer to the path to the application file. Here is the complete list of substitution tokens:

  • ${f}…The entire associated path (including file and extension)
  • ${F}…The entire application path (including file and extension)
  • ${p}…The path to the associated file
  • ${P}…The path to the application file
  • ${b}…The base associated file name
  • ${B}…The base application file name
  • ${x}…The associated file extension
  • ${X}…The application file extension

In the defaults for “vmrun.exe”, I entered text into the “Options” field that looked like:

start "${f}"

The literal text “start” in this example above is an application-defined value; “vmrun.exe” requires and expects it to be the first value it encounters if we are asking it to run a VM. Following that, I’ve added a substitution token that will provide me with the full path to the association file. Note that I’ve enclosed this token in quotation marks in case the path contains things like spaces that would cause the shell to choke.

When editing individual association values, the “Test” button to the right of the “Options” field is enabled. Pressing this button will cause the value in the “Options” field to be interpreted (i.e., tokens will be substituted from currently defined values), and it will display the results so you can ensure that you’ve properly formatted the values. For example:

Testing Options

In most cases, if you need substitution, you’ll be using just the ${f} token surrounded by quotation marks in your “Options”. However, if you leave the “Options” field empty, or there are no substitution tokens detected in the value entered into this field, Associated will automatically append the full path to the associated file to the end of the “Options” value (or as the “Options” value if it is empty).

[ The Rest of the Settings ]

Let’s quickly look at the remainder of the options in “Settings.”

At the top level, right-clicking on an empty area of the list will give you a context menu with these entries:

List Options

“Add Application” adds a new application entry to the list. Application entries must be unique; duplicates are not allowed.

“Paste” will appear on this top-level context menu if you have copied an application to the internal clipboard. See below for more detail about copying and pasting.

“Clear List” will clear the entire list of your defined applications (and associations). Be careful with this: It cannot be undone once you press “Ok” on the dialog.

For applications, you’ll get this context menu:

Application Options

“Add Association” has been covered. You use this to add new file associations to your application.

“Update” is used to change the application to which the entry points. This allows you to switch the application without having to rebuild your list of associations.

“Edit Defaults” has been covered. These defaults help you when adding associations.

“Reset Popularity Rating” will reset the popularity rating values to zero for all currently defined associations of this application.

“Elevated Privileges” should be enabled if the application requires elevated privileges to run. This executes the process with a “runas” verb. If enabled, you may be prompted to enter Administrator credentials in order to successfully launch the application.

“Launch Minimized” will launch the application so that it minimizes to the task bar. Turn this off to launch in a normal window.

“Enable Popularity” turns popularity sorting on or off for the selected application. Popularity counting continues even if popularity sorting is turned off.

“Copy” and “Paste” provide clipboard-like functions for the application. Copying the application makes it available for pasting to a new application entry. Pasting an application will require you to select a new application for the entry (no two entries can point at the same application) and all associated file entries will be copied to the new entry.

“Delete” will delete the application entry, along with all associated files.

For associations, this context menu is available:

Association Options

“Edit” allows you to edit the settings for this individual association.

“Reset Popularity Rating” is identical to the action for the application, except it will only apply to this association.

“Copy” and “Paste” are also identical to the application, except they only work with the selected association. Pasting the association will add it to the current application context (whether an application is explicitly selected, or an association within an application is selected). Since associations can be duplicated, you can quickly duplicate an association entry for an application by copying and pasting within the same application context. You can also hold down the Ctrl key while dragging an association to make a copy of it.

“Delete” will delete the individual association.

[ Legal ]

Associated uses the Qt Toolkit, which is Copyright © 2011 Nokia
Associated uses icons that are Copyright © 2010-2011 *Remitrom73

All else is Copyright © 2011 Bob Hood

Simply put: Associated is free software. You may use it in any environment you wish, whether commercial or personal, as long as you do so at your own risk. I accept no responsibility, real or imagined, for any damages caused by your usage of my software.

Enjoy.

Advertisements

2 thoughts on “Associated: A Windows Shell Extension

  1. bobhood says:

    VNC Viewer’s MRU list also has a tendency to drive me nuts. I end up with a large list of IP addresses, and I can’t always keep the associations between IP addresses and target machines in my head. Here are some quick steps to set up associations for VNC Viewer:

    • – Open VNC Viewer and enter/select the machine to which you want to connect.
    • – Open “Options” and set up the options for the connection.
    • – Connect to the machine, entering your access password if requested, and verify that the options settings work correctly.
    • – While connected to the machine, press F8 to open the Menu, and select “Options”.
    • – Go to the “Load/Save” tab and select “Save As”.
    • – Create a new *.vnc file that represents the connection and all of its settings (including the password, if you wish).
    • – Open Associated‘s settings, and add the new *.vnc file as an association to the VNC Viewer application with the “Options” line containing the following:
      • -config "${f}"
  2. – Give the association a meaningful name, and you’re done!

Comments are closed.