Pin (Unpin) to Start Menu / Taskbar
The script will check the registry value HKEY_CURRENT_USERSoftwareCompanyPinToStartMenu, If the Value of PinToStartMenu is 1 the script will quit. If the value is something else or string is missing the script will pin Outlook 2010, Word 2010, Excel 2010 and Powerpoint 2010 to the Start Menu. It will also unpin Windows Media Player from the Taskbar.
By first checking the if the registry value exist, users will only get the application pinned or unpinned the first time they log in, any modification they make to the start menu or taskbar will not be overwritten.
Either launch the script from your existing logonscript, or you could create a group policy object and launch the script from User ConfigurationPoliciesWindows SettingsScriptsLogon.
[code]
On Error Resume Next
const HKEY_CURRENT_USER = &H80000001
strKeyPath = “SoftwareCompany”
strValueName = “PinToStartMenu”
‘Read registry string
Set oReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!.rootdefault:StdRegProv”)
oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
IF strValue = 1 Then
‘ IF Registry Value is 1 then quit script
wscript.quit
Else
‘ IF Registry Value is missing or other than 1, (un)pin application.
‘ Declare
Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
‘ Create Object and set path to All Users Program Folder
Set objShell = CreateObject(“Shell.Application”)
Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
‘ Pin Outlook 2010 to Start Menu
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & “Microsoft Office”)
Set objFolderItem = objFolder.ParseName(“Microsoft Outlook 2010.lnk”)
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, “&”, “”) = “Pin to Start Menu” Then objVerb.DoIt
Next
‘ Pin Word 2010 to Start Menu
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & “Microsoft Office”)
Set objFolderItem = objFolder.ParseName(“Microsoft Word 2010.lnk”)
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, “&”, “”) = “Pin to Start Menu” Then objVerb.DoIt
Next
‘ Pin Excel 2010 to Start Menu
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & “Microsoft Office”)
Set objFolderItem = objFolder.ParseName(“Microsoft Excel 2010.lnk”)
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, “&”, “”) = “Pin to Start Menu” Then objVerb.DoIt
Next
‘ Pin PowerPoint 2010 to Start Menu
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & “Microsoft Office”)
Set objFolderItem = objFolder.ParseName(“Microsoft PowerPoint 2010.lnk”)
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, “&”, “”) = “Pin to Start Menu” Then objVerb.DoIt
Next
‘ Unpin Windows Media Player from Taskbar
Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
Set objFolderItem = objFolder.ParseName(“Windows Media Player.lnk”)
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, “&”, “”) = “Unpin from Taskbar” Then objVerb.DoIt
Next
‘ Write Registry Value to indicate that the script has run for the current user.
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,”1″
End IF
[/code]
You can read more about Pin Items to the Start Menu or Windows 7 Taskbar via Script over at the The Deployment Guys blog on TechNet