Unregistering a Server Scriptlet

Usually the registration for a COM component is accomplished in two ways—by the component itself through a function called DllRegisterServer (or DllRegisterServerEx) or by the means of a utility called regsvr32.exe which is located in the Windows directory. To be honest, even the utility ends up calling the DllRegisterServer function.

The Server Scriptlet Package comes with its own copy of the utility, so you don't have to worry about it—just install the package!

The syntax for registering a Server Scriptlet is straighforward:

regsvr32.exe sct_filename

where sct_filename is the name of the SCT file you want to register. This is because regsvr32 is a well-known utility for COM developers. I then need to take a look at the content of the Windows registry under the key:

HKEY_CLASSES_ROOT\

 .sct\

There you will learn that everything that defines the context menu for the SCT files is stored under another key: (see the figure)

HKEY_CLASSES_ROOT\

 scriptletfile\

Under such a registry key there should be a subtree called Shell that looks like in the next figure. All the subkeys defined here corresponds to items added to the context menu for the scriptlets file. As you can see, there are two items—Edit and Register. Compare this figure with the one showing the context menu, that we encountered earlier. The key Command for each item defines the program that actually executes after the click.

As you can see in the figure, the command line for Register is just:

c:\win95\system\regsvr32.exe "%1"

Of course the Windows path refers to my home computer. The "%1" means that the utility will receive the file currently highlighted in Windows Explorer. In other words, the file you have just right-clicked.

How to Unregister

If you ever used regsvr32.exe then you should know that by calling it this way:

regsvr32.exe /u filename

you will be able to unregister a COM object from the registry. The next step, therefore, is essential. You need to add a new "Unregister" item to the context menu with the following Command string:

 

regsvr32.exe /u "%1"

Using the Registry Editor (regedit.exe, located in the Windows directory) the next steps are pretty straightforward.

A dialog box will appear. Type in regsvr32.exe /u "%1". To make sure prefix with the actual path of your Windows\System directory.

Once this is completed turn back to the Explorer and right-click on a SCT file. The context menu now should be the following.

In this way you can register and unregister a Server Scriptlet with the greatest of ease. The next figure shows that unregistering this way really works!

Note that there's an error in what the beta version of the Server Scriptlet Package writes in your registry. It does not store the name of the application that will run if you right-click on the Edit voice. If you highlight the Edit key in the same subtree discussed here, you'll note that it attempts to run notepad.exe but from the System directory. This is an error, since Notepad resides in the Windows directory. To correct this, edit the correspondent Default string on the right-hand pane and remove the System subdirectory from the path.

© 1997 by Wrox Press. All rights reserved.