March 6th, 2006

How Can I Change the Internet Explorer Title Bar?

 

Hey, Scripting Guy! Question

Hey, Scripting Guy! I recently signed up with a new Internet service and now every time I start Internet Explorer the window title says Internet Explorer Provided by Fabrikam.com. How can I change the Internet Explorer title bar?

— AD

SpacerHey, Scripting Guy! AnswerScript Center

Hey, AD. You know, you’ve presented the Scripting Guys with a moral and ethical dilemma. Just about the same time we received your email we got a second email that read something like this:

“Hey, Scripting Guy! I know that a lot of companies have configured Internet Explorer so that each time their users start Internet Explorer the window title says Internet Explorer Provided by Fabrikam.com, and I’d like to do that too. How can I change the Internet Explorer title bar?”

So is it a good thing to have a title bar that says Internet Explorer Provided by Fabrikam.com or is it a bad thing to have a title bar that says Internet Explorer Provided by Fabrikam.com? Beats the heck out of us. But, then again , as Scripting Guys it’s not really our job to tell you which actions are good and which actions are evil. It’s just our job to provide people with scripts that can change the Internet Explorer title bar:

Const HKEY_CURRENT_USER = &H80000001

strComputer = “.”

Set objReg = GetObject(“winmgmts:\\” & strComputer & “\root\default:StdRegProv”)

strKeyPath = “SOFTWARE\Microsoft\Internet Explorer\Main” strValueName = “Window Title” strValue = “The Scripting Guys”

objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue

By default Internet Explorer displays the page title for any Web page it opens (or the URL if the page doesn’t have a title). The title is then followed by the phrase Microsoft Internet Explorer. To change this to some other phrase (or to delete the appended phrase altogether) you need to modify the registry value HKCU\Software\Microsoft\Internet Explorer\Main\Window Title. For example, after setting the value of Window Title to The Scripting Guys Internet Explorer will look like this:

Internet Explorer


Cool, huh? If you change Window Title to Internet Explorer Provided by Fabrikam.com, then that’s the phrase that will appear after the page title. If you change the value to an empty string (“”) then the only thing that will appear in the Internet Explorer title bar is the page name:

Internet Explorer

 

Note. What if you delete the registry value? In that case, Internet Explorer automatically reverts back to the default phrase Microsoft Internet Explorer.

Now that we know how the title bar works, how does the script work? Well, it starts off by defining a constant named HKEY_CURRENT_USER and setting the value to &H80000001; this tells the Standard Registry Provider (the WMI object we use to modify the registry) which registry hive we want to work with. We then use this line of code to bind to the Standard Registry Provider on the local computer:

Set objReg = GetObject(“winmgmts:\\” & strComputer & “\root\default:StdRegProv”)

And yes, unlike Windows Script Host’s registry methods, you can use the Standard Registry Provider to read from and write to the registry on a remote computer. All you have to do is assign the name of that remote machine to the variable strComputer.

After we make the connection we then assign values to three different variables:

•

strKeyPath is the the registry key where Window Title is found. In this case, that’s Software\Microsoft\Internet Explorer\Main.

•

strValueName is the name of the registry value we want to modify (Window Title).

•

strValue is the new value to be assigned to Window Title. Because Window Title has a data type of REG_SZ, strValue must be a string value. As we noted earlier, setting strValue to an empty string (“”) will result in no additional verbiage being added to the Internet Explorer title bar.

To actually change the registry value all we have to do is call the SetStringValue method, passing our constant and three variables (in this order):

objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue

And there you have it. If Window Title doesn’t exist, no problem: SetStringValue will first create the new registry value and then assign it the desired string.

That’s all we can do with this; from here on it’s up to each of you to decide how to best use this new-found knowledge. Choose wisely.


Author

0 comments

Discussion are closed.