PDA

View Full Version : code to set homepage


KingSteve
11-11-08, 14:47
i use a vb script that runs when users log on to the domain. is there a way to set the browser homepage with that script?

thanks

KingSteve
11-12-08, 08:08
i found a way but i cant seem to find the right syntax for it. has to do with editing the registry, specifically HKCU\Software\Microsoft\Internet Explorer\Main\Start Page

if anyone can help
thanks again

PC-XT
11-12-08, 10:37
I haven't tried this, but I think it would go something like const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page"
strValueName = "String Value Name" 'unless it's "Expanded String Value Name"
strValue = "http://www.google.com" 'or whatever homepage url

oReg.SetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
'or use oReg.SetExpandedStringValue if you use that strValueNameThis is from http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/registry/#CreateStringDword.htm

Also, I have seen some antimalware scanners detect a change in a registry location like this as possible evidence of malware, which you can ignore, as long as it's the value you set it too.

KingSteve
11-12-08, 11:26
hey thanks for your reply. what is the difference between the expanded string value name and string value name?

KingSteve
11-13-08, 12:55
yeha i dont know. i dont get any errors but it doesnt change the start page value. i tried stringvaluename and expanded with no errors but no successful output... any ideas??

KingSteve
11-13-08, 13:22
issue has been solved. thanks again for your reply!

the vb code to set the registry value for start page is

Set Shell = CreateObject( "WScript.Shell" )

Shell.RegWrite "HKCU\SOftware\Microsoft\Internet Explorer\Main\Start Page", "http://www.yahoo.com"

KingSteve
11-13-08, 14:00
the vb code to set the registry value for start page is

Dim Shell

Set Shell = CreateObject( "WScript.Shell" )

Shell.RegWrite "HKCU\SOftware\Microsoft\Internet Explorer\Main\Start Page", "http://www.yahoo.com"


i forgot the define the variable in my last post. the Dim Shell is what you have to add to the script. I used this as part of my user login script for the domain. It is primarily used for roaming profiles to set the default printers and whatnot in whatever computer lab theyre in at the time.

PC-XT
11-16-08, 20:15
Glad you got it working. I like using WShell better than winmgmts: objects, but everyone else says it's better so I have trouble finding WShell stuff. The winmgmts: objects don't seem to work for me, either. Thanks for giving the code.