VBScript - Set Homepage (MSIE) / Add Notepad to Send To

The following will set up your homepage (in Internet Explorer) via a VBScript file. Create a blank text file called 'sethome.vbs'. Running it will change your default home page. Useful for setting the home page via a login script (or after some spyware may have changed your homepage).
Set WSHShell = WScript.CreateObject("WScript.Shell")

' home page URL
StartPage = "http://www.google.co.uk"
WSHShell.RegWrite "HKLM\Software\Microsoft\Internet Explorer\Main\Start Page", StartPage
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", StartPage
This code will add notepad to the Send To menu (when you right click a file). Create a new file called 'sendtonotepad.vbs', containing the following code.
Set WSHShell = WScript.CreateObject("WScript.Shell")

Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")

sWinDir = oFSO.GetSpecialFolder(WindowsFolder)

sSendTo = WSHShell.SpecialFolders("SendTo")

Set oShortCut = WSHShell.CreateShortcut(sSendTo & "\Notepad.lnk")

With oShortCut
 .WindowStyle = 3
 .IconLocation = "notepad.exe, 0"
 .TargetPath = sWinDir&"\notepad.exe"
 .Save
End With
Should work with all versions of windows after 95 (95/98/ME/2k/XP) with Windows Scripting installed. The code will not run in a web page. To allow IE site visitors to set their homepage to the one they are on, simple paste the following into your page:
<!--[if IE]>
<a href="#" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage(location.href);">Set this page as your default homepage</a>
<![endif]-->
The latest version of Windows Scripting (required) can be found here

Popular posts from this blog

Select box manipulation with jQuery

Basic Excel Spreadsheet Generation (ASP/ASP.NET)

Link: HTML Agility Pack (.NET)