Introduction
This script shows how to lock the homepage in Internet Explorer.
Scenarios
Some applications will change customers' IE homepage.
This script is to lock IE homepage.
Script
Step 1: Double click the script and then it will show a dialog asking permission.
Step 2: Then there will be a dialog. If you want to lock current homepage, then press enter to continue. Otherwise enter the web site address you want to lock and press enter to continue.
Here are some code snippets for your references
'Run script with adminsitrator
If WScript.Arguments.Count = 0 Then
Dim objShell
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "cscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1
Else
'Create wscript.shell obejct
Set objshell = CreateObject("wscript.shell")
'Home page registry path
Homepath = "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page"
'Home page address
Homepage = objshell.RegRead(Homepath)
WScript.StdOut.Write "Do you want to lock " & Homepage & " as IE homepage?(If yes press ENTER, otherwise enter the site you want to set as homepage ):"
Choice = WScript.StdIn.ReadLine()
If Choice <> "" Then
Homepage = Choice
objshell.RegWrite Homepath, Homepage
End If
'Lock homepage
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\HomePage", 1, "REG_SZ"
WScript.Echo "Lock " & Homepage & " as IE homepage successfully."
wscript.Echo "Press enter to exit"
WScript.StdIn.ReadLine()
End If
'Run script with adminsitrator If WScript.Arguments.Count = 0 Then Dim objShell Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "cscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1 Else 'Create wscript.shell obejct Set objshell = CreateObject("wscript.shell") 'Home page registry path Homepath = "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page" 'Home page address Homepage = objshell.RegRead(Homepath) WScript.StdOut.Write "Do you want to lock " & Homepage & " as IE homepage?(If yes press ENTER, otherwise enter the site you want to set as homepage ):" Choice = WScript.StdIn.ReadLine() If Choice <> "" Then Homepage = Choice objshell.RegWrite Homepath, Homepage End If 'Lock homepage objShell.RegWrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\HomePage", 1, "REG_SZ" WScript.Echo "Lock " & Homepage & " as IE homepage successfully." wscript.Echo "Press enter to exit" WScript.StdIn.ReadLine() End If
Windows 8
Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.