How Can I Assign Multiple Home Pages to Internet Explorer 7.0?

ScriptingGuy1

Hey, Scripting Guy! Question

Hey, Scripting Guy! How can I configure Internet Explorer 7 so it uses multiple home pages?

— PI

SpacerHey, Scripting Guy! AnswerScript Center

Hey, PI. Just a second; before we begin, is anyone from Microsoft reading today’s column? Don’t be shy; raise your hand if you’re from Microsoft. No one, not a single Microsoft employee is reading today’s column? Excellent.

What difference does it make if someone from Microsoft reads today’s column? Well, all things considered, the Scripting Guy who writes this column would just as soon that no one he works with knows the horrible truth: the Scripting Guy who writes this column doesn’t actually use Internet Explorer 7. That’s right; he still uses Internet Explorer 6. Why? No real reason; he just likes Internet Explorer 6 better.

Like we said, though, that’s just between us. (Although it could be worse; he could be using Firefox or some other non-Microsoft browser.)

Anyway, because he still uses Internet Explorer 6 (and drives a Model T, and listens to music on a gramophone, and …) the Scripting Guy who writes this column didn’t even know that you could configure Internet Explorer 7 to use multiple home pages. As it turns out, however, you can. Which actually makes sense: multiple tabs means that you can open up multiples pages at once. So why not multiple home pages, pages that automatically load up, each on a separate tab, every time you start Internet Explorer?

And the best part of all? Writing a script to assign multiple home pages to Internet Explorer 7 is as easy as, well, as easy as this:

Const HKEY_CURRENT_USER = &H80000001

strComputer = “.”

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

strKeyPath = “SOFTWARE\Microsoft\Internet Explorer\Main” ValueName = “Start Page” strValue = “http://www.microsoft.com/technet/scriptcenter/default.mspx”

objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue

ValueName = “Secondary Start Pages”

strValue1 = “http://www.microsoft.com/technet/scriptcenter/resources/qanda/default.mspx” strValue2 = “http://www.microsoft.com/technet/scriptcenter/resources/begin/default.mspx” arrValues = Array(strValue1, strValue2)

objReg.SetMultiStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, arrValues

As you can probably tell from glancing at the code, in order to configure multiple home pages for Internet Explorer 7 we need to modify the registry; in particular, we need to modify the following two registry values:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page. This is the spot where we configure the primary home page, the one that shows up in the topmost tab in Internet Explorer. If this registry location sounds familiar to you, it should: this is the same registry value used to configure the home page in previous versions of Internet Explorer.

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Secondary Start Pages. This is a brand-new registry value, and just happens to be the spot where we configure the rest of our home pages. (Or, as Internet Explorer 7 terms them, “secondary home pages.”)This registry value doesn’t exist by default; if it did, then you’d already have multiple home pages. But don’t worry; creating this new registry value is nowhere near as difficult as you might think it would be. (Well, unless, of course, you don’t think it would be difficult at all.)

OK, so much for what we’re going to do; let’s talk about how we’re going to do it. To begin with, we define a constant named HKEY_CURRENT_USER and assign it the value &H80000001; we’ll use this constant to tell the script which registry hive we want to work with. (You’re right: we do want to work with the HKEY_CURRENT_USER hive.That’s because the Internet Explorer home page is configured on a per-user basis.) We then connect to the WMI service on the local computer, taking care to bind to the StdRegProv class which, unlike most of the WMI classes we work with, is found in the root\default namespace:

strComputer = “.”

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

Note. Could we run this same script against a remote computer? Of course we can; what fun would it be if we couldn’t? To configure multiple home pages on a remote computer, just assign the name of that computer to the variable strComputer, like so:

strComputer = “atl-ws-01”

After we connect to the WMI service, our next task is to assign values to three variables:

strKeyPath. This is the path (within the HKEY_CURRENT_USER hive) to the registry value we want to modify. In this case, that’s SOFTWARE\Microsoft\Internet Explorer\Main.

ValueName. The name of the registry value to be modified. For this script, that’s Start Page.

strValue. The value to be assigned as the primary home page. Needless to say, we opted for the page that all kind and decent people use as their home page: http://www.microsoft.com/technet/scriptcenter/default.mspx.

So then how do we actually make the Script Center home page the Internet Explorer home page? Like this:

objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue

As you can see, all we’re doing here is calling the SetStringValue method, passing the registry hive (the constant HKEY_CURRENT_USER), the registry path (strKeyPath), the registry value name (ValueName), and our new home page (strValue) as the method parameters.

Well, that was easy, wasn’t it? Now let’s see what we can do about those secondary home pages.

As we noted earlier, the URLs for secondary home pages (all of them) are stored in a registry value named Secondary Start Pages. That means the first thing we need to do is change the value of the variable ValueName:

ValueName = “Secondary Start Pages”

Note. How come we don’t change the value of the variable strKeyPath? There’s a very good reason for that: we don’t need to. That’s because Secondary Start Pages also resides in the registry key SOFTWARE\Microsoft\Internet Explorer\Main.

At this point, things get a tiny bit tricky. (But just a tiny bit.) The Secondary Start Pages registry value needs to have the data type REG_MULTI_SZ; that’s because this key (if needed) has to be able to hold multiple values. Fortunately, that’s no big deal; that simply means that any value we assign to this registry key must be passed as an array. That explains what this block of code is for:

strValue1 = “http://www.microsoft.com/technet/scriptcenter/resources/qanda/default.mspx”
strValue2 = “http://www.microsoft.com/technet/scriptcenter/resources/begin/default.mspx”
arrValues = Array(strValue1, strValue2)

In our first line of code, we’re assigning the URL for the Hey, Scripting Guy! column to a variable named strValue1. Why? Because we want Hey, Scripting Guy! to be one of our secondary home pages. In line 2, we assign the URL for the Sesame Script column to a variable named strValue2. Why? Because – oh, right. Guess you didn’t need our help to figure that out, did you?

Note. Can you create more than 2 secondary home pages? Yes you can, although, to be honest, we’re not sure what the limit is, or even if there is a limit.

That brings us to line 3, where we call VBScript’s Array function and add our two variables (strValue1 and strValue2) to an array named arrValues.

After we’ve done that we’re ready to call the SetMultiStringValue method and assign these two URLs to the registry value Secondary Start Pages. That’s what we do here:

objReg.SetMultiStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, arrValues

What’s that? Didn’t we say that, by default, the registry value Secondary Start Pages doesn’t exist? Yes, we did say that. But, as we also said, that’s no big deal. If this registry value exists then SetMultiStringValue will simply overwrite it; if the registry value doesn’t exit then SetMultiStringValue will first create it, and then assign it a new value. Talk about a win-win situation, huh?

At any rate, that should do it, PI. We’re sure that today’s column has generated even more questions about working with Internet Explorer 7; for example, no doubt some of you are wondering how to delete these secondary start pages, or maybe how to delete one of the secondary start pages (while leaving the other alone). We’ll address some of these questions in the very near future, albeit not today. But that’s all right; after all, you need some time to play around with the script that assigns multiple home pages. And the Scripting Guy who writes this column needs some time to actually install and start using Internet Explorer 7.

Although, if anyone asks, he’s been using it all along.

0 comments

Discussion is closed.

Feedback usabilla icon