2008-10-23

Add an IE Favorite to a User Profile via VBScript

If your company has an IT support website or any other website people need to visit regularly, but never bookmark then this is a handy logon script.

This script creates a shortcut both on the desktop and in IE for the specified website. It is also possible to set a custom icon for the link (I used my company's logo), but that is 100% optional. The icon code is commented out below. Without it your link will have the default Internet Explorer icon.

All you need to do is change "http://example.com" to the website you want to link to.







'------------------------------
'Author: Christopher Maddalena
'Date: October 17, 2007
'Purpose: Create an IE shortcut for example.com on the user's desktop and favorites list.
'How: The script checks for the existence of the shortcut and, if it does not exists, creates it.
' The shortcut is created in two places under the name "IT SUPPORT.url":
' 1) In the current user's Favorites list in IE.
' 2) In the All Users desktop directory.
' The desktop shortcut is made slightly differently as an .LNK to allow for changing the icon.
'------------------------------

Option Explicit
Call Main()
WScript.Quit(0)

On Error Resume Next

Sub Main
Dim objShell, objShortcut

'Create the desktop shortcut
Set objShell = CreateObject("WScript.Shell")
Set objShortcut = objShell.CreateShortcut("C:\Documents and Settings\All Users\Desktop\IT SUPPORT.url")
objShortcut.TargetPath = objShell.ExpandEnvironmentStrings("http://example.com")
'objShortcut.IconLocation = "\\FOLDER_PATH\ICON.ICO"
objShortcut.Save

'Create the IE favorite
Set objShell = CreateObject("WScript.Shell")
Set objShortcut = objShell.CreateShortcut("C:\Documents and Settings\All Users\Favorites\IT SUPPORT.url")
objShortcut.TargetPath = objShell.ExpandEnvironmentStrings("http://example.com")
'objShortcut.IconLocation = "\\FOLDER_PATH\ICON.ICO"
objShortcut.Save
End Sub

No comments: