How Can I Change the Internet Explorer Home Page?

Hey, Scripting Guy! Question

Hey, Scripting Guy! Can I change the Internet Explorer home page by using a script?

— AH

SpacerHey, Scripting Guy! AnswerScript Center

Hey, AH. It’s Monday morning, and after a hard weekend of sitting around watching football, we decided to take it easy this morning. Yes, you can change the Internet Explorer home page by using a script; all you have to do is write a WMI script that modifies the HKCU\ SOFTWARE\Microsoft\Internet Explorer\Main\Start Page registry value:

Const HKEY_CURRENT_USER = &H80000001

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

strKeyPath = “SOFTWARE\Microsoft\Internet Explorer\Main”
ValueName = “Start Page”
strValue = “”
objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue

Boy, when we said we were going to take it easy this morning, we weren’t kidding, were we? As you can see, there’s not much to this script. We start by defining the constant HKEY_CURRENT_USER, setting the value to &H80000001; as we’ve noted in previous columns, this value tells our script to work with the HKCU portion of the registry. We then connect to the WMI service; note that the class used to modify registry values – StdRegProv – is in the root\default namespace (which makes it different from the hundreds of WMI scripts you’re probably most familiar with, almost all of which connect to the root\cimv2 namespace).

After that, we assign the registry path and the registry value to a pair of variables (strKeyPath and ValueName, respectively). We then assign our new home page — — to the variable strValue. Once we get all these variables set, we then call the SetStringValue method to actually change the registry and, in turn, change the Internet Explorer home page. (As you no doubt figured out, each time Internet Explorer starts up, it checks HKCU\ SOFTWARE\Microsoft\Internet Explorer\Main\Start Page to determine the home page.)

The end result: a script that sets the home page of the current user to the TechNet Script Center. (Yeah, we know: that is kind of silly. After all, who doesn’t already have their home page set to the TechNet Script Center?)

Incidentally, Internet Explorer makes extensive use of the registry; in turn, that means you can easily write scripts that configure Internet Explorer settings. If you just can’t wait to do this, check out the Tweakomatic utility, which includes scores of scripts useful in managing Internet Explorer. Or, just sit tight for a couple weeks and wait until we get all those scripts added to the Script Repository.

Why don’t we just add all those scripts today? Didn’t we mention that it was Monday? We’ll get them up soon.

By the way, if all you want to do is determine the current home page configured for a user, try this script:

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = “.”
Set objReg = GetObject(“winmgmts:\\” & strComputer & “\root\default:StdRegProv”)
strKeyPath = “SOFTWARE\Microsoft\Internet Explorer\Main”
ValueName = “Start Page”
objReg.GetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue

If IsNull(strValue) Then
Wscript.Echo “The value is either Null or could not be found in the registry.”
Wscript.Echo strValue
End If

Comments (4)

  1. Galo says:

    Hey there I have a problem with my start page. IT dept has blocked us the ability to change our home page. However that page has been changed after I visited any webpage. I have run my regedit and changed the "HKCU SOFTWAREMicrosoftInternet ExplorerMainStart Page" registry value to the corporate one. Everything looked fine but after I reboot the machine the intruder home page is there again. Please I need some help to prevent reocurrence.

  2. Paulie D says:

    Your "Tweakomatic" link points to http://null/yada..

  3. Paulie D says:

    The correct Tweakomatic link is:…/twkmatic.mspx