Windows DevCenter    
 Published on Windows DevCenter (http://www.windowsdevcenter.com/)
 See this if you're having trouble printing code examples


Adding Custom Buttons to Internet Explorer

by Mitch Tulloch, author of Windows Server Hacks
04/26/2005

Have you ever wanted to extend the Internet Explorer toolbar by adding your own buttons? Say you wanted to add a button that launched Skype, for example, or some other tool you frequently need to access when browsing the Web. Or maybe you'd like a button that launches a script that opens your company intranet home page in a new IE window. Perhaps you'd like a button that does some other custom action, such as launching Notepad (if you're cheap) or OneNote (if you're more sophisticated) to jot down some notes. Or maybe you need to allow users to perform some action on a kiosk machine that allows access only to IE and not the Start menu or desktop. Here's how you can do things like that, and more.

Step 1: Create Icons

To create icon files that can be used for your custom button, you need a third-party tool. A good one is IconWorkshop from Axialis Software, which has a 30-day free evaluation version you can try out. As an example, let's add a button to IE that opens a JPEG photo of me in your default image editor. (I'm vain.) First you need a recent photo of me:

Figure 1
Figure 1. Donald Trump, eat your heart out!

Now start Icon Workshop and open the image file above:

Figure 2
Figure 2. Getting ready to make an icon of myself.

Press Ctrl-A to select the image, and then choose Create New Icon From Selection from the Image menu. In the New Icon From Image dialog box, type a name for the icon file, and accept the remaining defaults to create Windows XP-compatible icons:

Figure 3
Figure 3. Turning myself into an icon.

After clicking on OK to create the icons, choose Save from the File menu to save the icons as an icon (.ico) file somewhere on your hard drive.

Now take your original JPEG and convert it to a grayscale image using Microsoft Photo Editor or some other tool. Then start Icon Workshop again, open your grayscale image file, and follow the steps above. Save your grayscale icons as a different icon file on your hard drive, and you're ready for the next step of the process.

Step 2: Create the Toolbar Button

To create the toolbar button using the above icons, we'll use Group Policy to customize the Internet Explorer interface. The policy we need to configure is this:


User Configuration\Windows Settings\Internet Explorer Maintenance\
   Browser User Interface

For simplicity, let's just use local Group Policy to configure this policy on a single machine. It's easy to extend the procedure below to domain Group Policy. To do it, use a domain Group Policy Object (GPO) instead of the Local Group Policy Object (LGPO). Note: Group Policy works only with XP Professional, not XP Home.

To open the LGPO on your XP desktop, click on Start, and then Run. Type gpedit.msc, and click on OK. This opens the Group Policy Object Editor. Expand the left pane to select the policy described above:

Figure 4
Figure 4. Selecting the policy to configure.

Now open the Browser Toolbar Customizations policy by double-clicking on it:

Figure 5
Figure 5. Configuring the policy.

Click on Add and specify a name for your new toolbar button, the executable or script that will run when the button is clicked, and the two icon files you previously created:

Figure 6
Figure 6. Details of configuring the toolbar button.

Here we've configured the button to run a batch file named mitch.bat, which contains a single command:


cmd /c "start http://www.mtit.com/mitch/hacks.htm"

Click on OK twice, and the policy will be immediately applied since we're configuring local Group Policy here. (If we used domain policy, then we'd have to either wait for the next refresh interval or force a policy refresh immediately using gpupdate /force.)

Step 3: Testing the Button

Now we're ready to test our new IE toolbar button. Open IE and hover the mouse pointer over the button to see the button name as a tool tip:

Figure 7
Figure 7. Note the funky new toolbar button. (Dude, hire a graphic designer next time....)

Now click on the toolbar button, and a new page will load:

Figure 8
Figure 8. The result of clicking on the new toolbar button.

Talk about shameless self-promotion!

Mitch Tulloch is the author of Windows 2000 Administration in a Nutshell, Windows Server 2003 in a Nutshell, and Windows Server Hacks.

Windows Server Hacks

Related Reading

Windows Server Hacks
100 Industrial-Strength Tips & Tools
By Mitch Tulloch

Return to the Windows DevCenter.

Copyright © 2009 O'Reilly Media, Inc.