locked
[SOLVED] How to Pin to Start Menu/Task Bar for Default User RRS feed

  • Question

  • Is it possible to pin items to the start menu and task bar for the default user so that when a new user logs on, they have whats been customized?
    The setting the Copy Profile to true doesn't seem to catch these customizations.

    If its not possible, what work-arounds could I employ to pin specific apps to both the Start Menu and Task Bar?


    • Edited by JuliusPIV Friday, May 6, 2011 3:44 AM
    Tuesday, April 6, 2010 6:25 PM

Answers

  • Many possibilities here...

    I've been able to use the CopyProfile command to keep items that I've pinned to the Start Menu, but not the things that I've pinned to the Taskbar.

    However, you can define up to five things that you want everyone to have pinned to their Taskbar using the unattend.xml files...that's one way of getting things there, unfortunately, that does not get rid of the "default" MS items that are already there (IE, MediaPlayer, etc).

    Here's a way to do it using a script though:

    http://blogs.technet.com/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx

    You could in theory also configure these things using Group Policy Preferences.  There are two components to the Taskbar items, one is a registry key and the other is a file system shortcut.  The registry keys define what is there and in what order the items appear on the taskbar.  If you use GPP you could set both of those things up for all new profiles.

    However, I'm leaning towards using the script and something like Active Setup which will allow you to run a one-time command for every new user that logs in to a box.  That way I can remove the things I don't want and add in the ones that I do...

     


    Mike N.
    • Proposed as answer by Dale Qiao Wednesday, April 7, 2010 1:04 AM
    • Marked as answer by Dale Qiao Tuesday, April 13, 2010 1:37 AM
    Tuesday, April 6, 2010 7:40 PM
  • Thanks for not only the link (Mike) but also the feedback (HendersonD).

    Using the information found in the link in Mikes post (either I used the link he posted or relentless searching proved useful and paid off!) , I created my own script to pin and unpin items on the Taskbar and Start Menu.  Also, after lots of digging around, I found the solution to getting rid of all the other items that appear on the Start Menu by default (displaySwitch, Remote Desktop, Getting Started etc).

    Although the script works, in that I get the desired outcome, I have a feeling I goofed on the code so its 'shot gunning' the stuff I don't want.  If anyone wants to help and provide feedback I'd love to hear it.

    Background:
    There were items on the Taskbar and Start Menu we wanted to customize.  The SIM allowed us to configure only a certain amount of shortcuts, far less than we needed/wanted.  So, it was back to inventing the wheel.
    The bulk of the items that appear on the Start Menu are stored in the registry.  (Yay!)
    However they're encrypted.  (Boo!)
    However, its only ROT13 so its easily defeated.  (Back to Yay again!)

    The script attempts to enumerate whats in "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist" converting it from ROT13 back to something useful so we can see what it is.  I could hard code what I don't want, but that would be too easy!  I wanted something portable this way I wouldn't have to worry about GUID's changing from machine to machine, or adding/removing things that sneak up on us in the future.  (Right Dale!?)

    Currently, as I hinted above, I think the script is removing all the values in there.  Its not a bad thing necessarily, but I would feel more comfortable if it behaved the way I want it to.  I suspect others might agree in that that I/We, the programmer, should be in control of our scripts; we should know what's happening not have a "Well, that is odd and can't be explained, but hey, the problem is fixed, right?" attitude.  (read: we should not just let whatever happens, happen.)
    Having said that, I suspect the problem lies within the logic of decrypting and checking the [decrypted] sting for a match against an array or comma separated string.  If someone wants to help with this great.  Otherwise, it *should* work as expected.

    This runs on a per-user basis at first sign-on:
    reg load HKU\DefUser "c:\Users\Default\NTUSER.DAT"
    reg add "HKU\DefUser\Software\Microsoft\Windows\CurrentVersion\Runonce" /v PinUnpin /t REG_EXPAND_SZ /d "%windir%\system32\wscript.exe path\to\pinunpin.vbs" /f
    reg unload HKU\DefUser

    Dale: I forgot about Active Setup, that might be more appropriate.

     

    '==========================================================================
    '
    ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2009
    '
    ' NAME: Pin & Unpin items to/from Start Menu & Taskabar
    '
    ' AUTHOR: JuliusPIV 
    ' DATE : 4/8/2010
    '
    ' COMMENT: 
    '
    '==========================================================================
    
    Dim sPath, sPinSMArray, sPinTBArray, sUnpinTBArray, PinItem
    Dim sMOW, sMOO, sFOX, sLN, sNuance, siMAN, sEXP, sWMP
    Const CSIDL_COMMON_PROGRAMS = &H17 
    Const CSIDL_PROGRAMS = &H2 
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oShell = CreateObject("Shell.Application") 
    Set wshshell = CreateObject("WScript.Shell")
    Set oAllUsersProgramsFolder = oShell.NameSpace(CSIDL_COMMON_PROGRAMS)
    
    sPath = oAllUsersProgramsFolder.Self.Path & "\"
    sMOW = "Microsoft Office Word 2007.lnk"
    sMOO = "Microsoft Office Outlook 2007.lnk"
    sFOX = "Mozilla Firefox.lnk"
    sLN = "Notes.lnk"
    sNuance = "Nuance PDF Professional 6\PDF Converter Professional.lnk"
    siMAN = "iManage.lnk"
    sEXP = wshshell.ExpandEnvironmentStrings("%WinDir%") & "\Explorer.exe"
    sWMP = wshshell.ExpandEnvironmentStrings("%ProgramFiles%") & "\Windows Media Player\wmplayer.exe"
    
    sPinSMArray = Array(sLN,sFOX,sMOO,sMOW,sNuance)
    sPinTBArray = Array(sMOO,sMOW,sFOX)
    sUnpinTBArray = Array(sEXP,sWMP)
    
    dim strScriptHost, output_echo
    strScriptHost = LCase(Wscript.FullName)
    If Right(strScriptHost, 11) = "wscript.exe" Then
     output_echo = False
    Else
     output_echo = True
    End If
    
    'Clearing out useless Start Menu icons
    EnumKeys "HKCU","Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist"
    
    WScript.Sleep(5000)
    
    Dim item
    For Each item In sPinSMArray
    	If Not fso.FileExists(sPath & item) Then
    		PinItem = False
    		debugecho "File, " & item & ", to pin does not exist in " & sPath & "."
    		debugecho "Please check the input and try again."
    		'WScript.quit
    	Else
    		PinSM(sPath & item)
    	End If
    Next
    
    For Each item In sPinTBArray
    	If Not fso.FileExists(sPath & item) Then
    		PinItem = False
    		debugecho "File, " & item & ", to pin does not exist in " & sPath & "."
    		debugecho "Please check the input and try again."
    		'WScript.quit
    	Else
    		PinTB(sPath & item)
    	End If
    Next
    
    For Each item In sUnpinTBArray
    	If Not fso.FileExists(item) Then
    		PinItem = False
    		debugecho "File, " & item & ", to unpin does not exist in " & sPath & "."
    		debugecho "Please check the input and try again."
    		'WScript.quit
    	Else
    		UnpinTB(item)
    	End If
    Next
    
    
    WScript.quit
    
    
    
    Function PinSM(shortcut)
    	On Error Resume Next
    	Set fso = CreateObject("Scripting.FileSystemObject")
    	Set oShell = CreateObject("Shell.Application") 
    	
    	sFolder = fso.GetParentFolderName(shortcut)
    	sFile = fso.GetFileName(shortcut)
    
    	debugecho "Pinning " & sFolder & "\" & sFile & " to Start Menu."
    	Err.Clear
    			
    	Set oFolder = oShell.NameSpace(sFolder)
    	Set oFolderItem = oFolder.ParseName(sFile)
    	Set colVerbs = oFolderItem.Verbs
    
    	For Each itemverb In oFolderItem.Verbs
    		If Replace(itemverb.name, "&", "") = "Pin to Start Menu" Then itemverb.DoIt
    	Next
    	On Error GoTo 0
    End Function
    
    Function PinTB(shortcut)
    	On Error Resume Next
    	Set fso = CreateObject("Scripting.FileSystemObject")
    	Set oShell = CreateObject("Shell.Application") 
    	
    	sFolder = fso.GetParentFolderName(shortcut)
    	sFile = fso.GetFileName(shortcut)
    
    	debugecho "Pinning " & sFolder & "\" & sFile & " to Taskbar."
    	Err.Clear
    			
    	Set oFolder = oShell.NameSpace(sFolder)
    	Set oFolderItem = oFolder.ParseName(sFile)
    	Set colVerbs = oFolderItem.Verbs
    	
    	For Each itemverb In oFolderItem.Verbs
    		If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt
    	Next
    	On Error GoTo 0
    End Function
    
    Function UnpinTB(shortcut)
    	On Error Resume Next
    	Set fso = CreateObject("Scripting.FileSystemObject")
    	Set oShell = CreateObject("Shell.Application") 
    	
    	sFolder = fso.GetParentFolderName(shortcut)
    	sFile = fso.GetFileName(shortcut)
    
    	debugecho "Unpinning " & sFolder & "\" & sFile & " from Taskbar."
    	Err.Clear
    			
    	Set oFolder = oShell.NameSpace(sFolder)
    	Set oFolderItem = oFolder.ParseName(sFile)
    	Set colVerbs = oFolderItem.Verbs
    	
    	For Each itemverb In oFolderItem.Verbs
    		If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt
    	Next
    	On Error GoTo 0
    End Function
    
    Function debugecho(msg)
    	if output_echo Then
    		wscript.echo msg
    	end if
    end Function
    
    Function EnumKeys(HKEY,Path)
    	Dim EKHKPath, GUIDPath, arrSubKeys, i
    	Select Case HKEY
    		Case "HKCU", "HKEY_CURRENT_USER"
    			Const HKCU = &H80000001
    			EKHKPath = HKCU
    		Case "HKLM", "HKEY_LOCAL_MACHINE"
    			Const HKLM = &H80000002
    			EKHKPath = HKLM
    		Case "HKU", "HKEY_USERS"
    			Const HKU = &H80000003
    			EKHKPath = HKU
    		Case "HKCR", "HKEY_CLASSES_ROOT"
    			Const HKCR = &H80000000
    			EKHKPath = HKCR
    		Case "HKCC", "HKEY_CURRENT_CONFIG"
    			Const HKCC = &H80000005
    			EKHKPath = HKCC
    		Case "HKDD", "HKEY_DYN_DAT"
    			Const HKDD = &H80000006
    			EKHKPath = HKDD
    		Case Else
    			WScript.Echo "ERROR: Invalid HKEY Type Specified (" & EKHKPath & ")"
    			WScript.echo "Please use HKCU, HKLM etc, or the long name equivalent."
    			WScript.Sleep(15000)
    			WScript.Quit
    	End Select
    	
    	Set objReg=GetObject("winmgmts:\\.\root\default:StdRegProv")
    	objReg.EnumKey EKHKPath, Path, arrSubKeys
    
    	if isarray(arrSubKeys) Then
    		For i=0 to UBound(arrSubKeys)
    			GUIDPath = Path & "\" & arrSubKeys(i) & "\Count"
    			'WScript.Echo "GuidPath: " & GUIDPath
    			EnumValues HKEY,GUIDPath
    			
     		Next
    	end If
    
    End Function
    
    Function EnumValues(HKEY,Path)
    	Dim EVHKPath, arrValueNames, arrValueTypes, i
    	
    	const REG_SZ = 1
    	const REG_EXPAND_SZ = 2
    	Const REG_BINARY = 3
    	Const REG_DWORD = 4
    	Const REG_MULTI_SZ = 7
     
    	Select Case HKEY
    		Case "HKCU", "HKEY_CURRENT_USER"
    			Const HKCU = &H80000001
    			EVHKPath = HKCU
    		Case "HKLM", "HKEY_LOCAL_MACHINE"
    			Const HKLM = &H80000002
    			EVHKPath = HKLM
    		Case "HKU", "HKEY_USERS"
    			Const HKU = &H80000003
    			EVHKPath = HKU
    		Case "HKCR", "HKEY_CLASSES_ROOT"
    			Const HKCR = &H80000000
    			EVHKPath = HKCR
    		Case "HKCC", "HKEY_CURRENT_CONFIG"
    			Const HKCC = &H80000005
    			EVHKPath = HKCC
    		Case "HKDD", "HKEY_DYN_DAT"
    			Const HKDD = &H80000006
    			EVHKPath = HKDD
    		Case Else
    			WScript.Echo "ERROR: Invalid HKEY Type Specified (" & EVHKPath & ")"
    			WScript.echo "Please use HKCU or the long name equivalent, HKEY_LOCAL_MACHINE."
    			WScript.Sleep(15000)
    			WScript.Quit
    	End Select
    
    	Set oReg=GetObject("winmgmts:\\.\root\default:StdRegProv")
    	oReg.EnumValues EVHKPath, Path, arrValueNames, arrValueTypes
    	
    	if isarray(arrValueNames) Then
    		For i=0 to UBound(arrValueNames)
    			'WScript.Echo "Unencrypted Value Name: " & arrValueNames(i)
    			arrValueNames(i) = Rot13Fixer(arrValueNames(i))
     		'WScript.Echo "Value Name: " & arrValueNames(i)
    ' #region Disabled code
    ' 	 	Select Case arrValueTypes(i)
    ' 		Case REG_SZ
    ' 		 		WScript.Echo "Data Type: String"
    ' 		 Case REG_EXPAND_SZ
    ' 				WScript.Echo "Data Type: Expanded String"
    ' 		 Case REG_BINARY
    ' 	 	 WScript.Echo "Data Type: Binary"
    ' 		Case REG_DWORD
    ' 					WScript.Echo "Data Type: DWORD"
    ' 		 Case REG_MULTI_SZ
    ' 					WScript.Echo "Data Type: Multi String"
    ' 			End Select
    ' #endregion
    		'WScript.Echo "this: " & HKEY & " " & Path & " " & arrValueNames(i)
    		FixStartMenu HKEY, Path, arrValueNames(i)
    		Next
    	End If
    End Function
    
    Function Rot13Fixer(sString)
    	Dim n, i, StringROT
    	For i=1 To Len(sString)
    		If Not IsNumeric(Mid(sString,i,1)) Then
    			individual_asc = Asc(Mid(sString,i,1))
    			'WScript.Echo "IASC: " & Chr(individual_asc) & " (" & individual_asc & ")"
    			If individual_asc >= 97 And individual_asc <=109 Then
    				individual_asc = individual_asc +13
    				'WScript.Echo "IASC+13.1: " & Chr(individual_asc) & " (" & individual_asc & ")"
    			Else
    				If individual_asc >= 110 And individual_asc <= 122 Then
    					individual_asc = individual_asc -13
    					'WScript.Echo "IASC-13.1: " & Chr(individual_asc) & " (" & individual_asc & ")"
    				Else
    					If individual_asc >= 65 And individual_asc <= 77 Then
    						individual_asc = individual_asc +13
    						'WScript.Echo "IASC+13.2: " & Chr(individual_asc) & " (" & individual_asc & ")"
    					Else
    						If individual_asc >= 78 And individual_asc <= 90 Then
    							individual_asc = individual_asc -13
    							'WScript.Echo "IASC-13.2: " & Chr(individual_asc) & " (" & individual_asc & ")"
    						End If
    					End If
    				End If
    			End If
    			StringROT = StringROT + Chr(individual_asc)
    		Else StringROT = StringROT + Mid(sString,i,1)
    		End If
    		'WScript.Echo StringROT
    	Next
    	Rot13Fixer = StringROT
    End Function
    
    Function FixStartMenu(HKEY, Path, ValueName)
    	Dim FSMPath, encValueName, arrDeleteApps
    	Select Case HKEY
    		Case "HKCU", "HKEY_CURRENT_USER"
    			Const HKCU = &H80000001
    			FSMPath = HKCU
    		Case "HKLM", "HKEY_LOCAL_MACHINE"
    			Const HKLM = &H80000002
    			FSMPath = HKLM
    		Case "HKU", "HKEY_USERS"
    			Const HKU = &H80000003
    			FSMPath = HKU
    		Case "HKCR", "HKEY_CLASSES_ROOT"
    			Const HKCR = &H80000000
    			FSMPath = HKCR
    		Case "HKCC", "HKEY_CURRENT_CONFIG"
    			Const HKCC = &H80000005
    			FSMPath = HKCC
    		Case "HKDD", "HKEY_DYN_DAT"
    			Const HKDD = &H80000006
    			FSMPath = HKDD
    		Case Else
    			WScript.Echo "ERROR: Invalid HKEY Type Specified (" & EVHKPath & ")"
    			WScript.echo "Please use HKCU or the long name equivalent, HKEY_LOCAL_MACHINE."
    			WScript.Sleep(15000)
    			WScript.Quit
    	End Select
    	
    	arrDeleteApps = Array("microsoft.windows.gettingstarted","displayswitch.exe","microsoft.windows.remotedesktop","microsoft.windows.stickynotes","snippingtool.exe" &_
    		"calc.exe","mspaint.exe","xpsrchvw.exe","wfs.exe","magnify.exe","welcome center.lnk","displayswitch.lnk","remote desktop connection.lnk","sticky notes.lnk" &_
    		"snipping tool.lnk","calculator.lnk","paint.lnk","xps viewer.lnk","windows fax and scan.lnk","magnify.lnk")
    
    	For i=0 To UBound(arrDeleteApps)		
    		If (instr(1,lcase(ValueName), lcase(deleteapps),1) > 0) Then
    			'WScript.Echo "hit"
    			encValueName = Rot13Fixer(ValueName)
    			Set oReg=GetObject("winmgmts:\\.\root\default:StdRegProv")
     			oReg.DeleteValue HKCU,Path,encValueName
     		End If
     	Next
    
    End Function
    
    

     

    • Marked as answer by JuliusPIV Friday, May 28, 2010 11:12 AM
    Friday, May 28, 2010 11:08 AM
  • Also, here's an optimized version of your script (code is a little bit tidier and functions have been optimized to avoid calling the same function too many times).

    Last thing, I noticed that just removing the .lnk files removes the application from the start menu. I think that the items with the .exe extension is just so that Windows knows how many times a certain application was used so that it can be pushed up/down the list on the start menu. Because of that, I am not touching the .exe files.

     

    '=-=-=-=-=-=-=-=-=-=-=-=-=
    '           CONSTS
    '=-=-=-=-=-=-=-=-=-=-=-=-=
    Const HKEY_CLASSES_ROOT     = &H80000000
    Const HKEY_CURRENT_USER     = &H80000001
    Const HKEY_LOCAL_MACHINE     = &H80000002
    Const HKEY_USERS             = &H80000003
    Const HKEY_CURRENT_CONFIG     = &H80000005

    Const CSIDL_COMMON_PROGRAMS    = &H17
    Const CSIDL_PROGRAMS        = &H2

    '=-=-=-=-=-=-=-=-=-=-=-=-=
    '          OBJECTS
    '=-=-=-=-=-=-=-=-=-=-=-=-=
    Set objRegistry            = GetObject("winmgmts:\\.\root\default:StdRegProv")
    Set objFSO                = CreateObject("Scripting.FileSystemObject")
    Set objApplication        = CreateObject("Shell.Application")
    Set objAllUsersPrograms    = objApplication.NameSpace(CSIDL_COMMON_PROGRAMS)
    Set objUserPrograms        = objApplication.NameSpace(CSIDL_PROGRAMS)

    '=-=-=-=-=-=-=-=-=-=-=-=-=
    '          VARIABLES
    '=-=-=-=-=-=-=-=-=-=-=-=-=
    Dim arrSubValues, arrDeleteApps, arrPinApps, strAllUsersProgramsPath

    strAllUsersProgramsPath    = objAllUsersPrograms.Self.Path & "\"
    strUserProgramsPath        = objUserPrograms.Self.Path & "\"
    arrDeleteApps            = Array("displayswitch.lnk", "remote desktop connection.lnk", "sticky notes.lnk", "snipping tool.lnk", "calculator.lnk", "paint.lnk", "xps viewer.lnk", "windows fax and scan.lnk")


    Call Main

    Sub Main()
        DeleteStartMenuApps HKEY_CURRENT_USER, "", arrDeleteApps

        DoVerb "Pin to Start Menu", strUserProgramsPath & "Internet Explorer.lnk"
       
        'Get the version of Office installed, so that we can pin it to the start menu
        If IsProgramInstalled(objRegistry, "Microsoft Office Enterprise 2007") = TRUE Then
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Office Word 2007.lnk"
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Office Excel 2007.lnk"
        Else   
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Word 2010.lnk"
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Excel 2010.lnk"
        End If
    End Sub


    '=-=-=-=-=-=-=-=-=-=-=-=-=
    '     FUNCTIONS AND SUBS
    '=-=-=-=-=-=-=-=-=-=-=-=-=
    Function DoVerb(strVerb, strPath)
        On Error Resume Next
            strFolder    = objFSO.GetParentFolderName(strPath)
            strFile        = objFSO.GetFileName(strPath)
           
            Set objFolder        = objApplication.NameSpace(strFolder)
            Set objFolderItem    = objFolder.ParseName(strFile)
           
            For Each ItemVerb In objFolderItem.Verbs
                If StrComp(Replace(ItemVerb.Name, "&", ""), strVerb, vbTextCompare) = 0 Then
                    ItemVerb.DoIt
                    Exit Function
                End If
            Next
        On Error Goto 0
    End Function

    Sub DeleteStartMenuApps(hDefKey, sSubKeyUser, arrDeleteApps)
        If Len(sSubKeyUser) > 0 Then
            sSubKeyName = sSubKeyUser & "\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist"
        Else
            sSubKeyName = "Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist"
        End If   
       
        objRegistry.EnumKey hDefKey, sSubKeyName, arrSubKeys
       
        If IsArray(arrSubKeys) Then
            For i = 0 to UBound(arrSubKeys)
                sTempSubKeyName = sSubKeyName & "\" & arrSubKeys(i) & "\Count"
                objRegistry.EnumValues hDefKey, sTempSubKeyName, arrSubValues
            
                If IsArray(arrSubValues) Then
                    For m = 0 to UBound(arrSubValues)
                        For n = 0 to UBound(arrDeleteApps)
                            If InStr(UCase(RunROT13(arrSubValues(m))), UCase(arrDeleteApps(n))) > 0 Then
                                objRegistry.DeleteValue hDefKey, sTempSubKeyName, arrSubValues(m)
                            End If
                        Next
                    Next
                End If
            Next
        End If
    End Sub


    Function RunROT13(strInput)
        For i = 1 to Len(strInput)
            iChr = Asc(Mid(strInput, i, 1))
            If (iChr >= 65 and iChr <= 77) Or (iChr >= 97 and iChr <= 109) Then
                strOutput = strOutput & Chr(iChr +13)
            ElseIf (iChr >= 78 and iChr <= 90) Or (iChr >= 110 and iChr <= 122) Then
                strOutput = strOutput & Chr(iChr -13)
            Else
                strOutput = strOutput & Chr(iChr)
            End If
        Next

        RunROT13 = strOutput
    End Function

    Function IsProgramInstalled(objRegistry, strProgramDisplayName)
        intRegistryHive    = HKEY_LOCAL_MACHINE
        strRegistryKey    = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
       
        objRegistry.EnumKey intRegistryHive, strRegistryKey, arrSubkeys
       
        IsProgramInstalled = FALSE
       
        For Each strSubkey In arrSubkeys
            strDisplayName = ReadRegistryValue(objRegistry, "STRING", intRegistryHive, strRegistryKey & "\" & strSubkey, "DisplayName")
           
            If UCase(strDisplayName) = UCase(strProgramDisplayName) Then
                IsProgramInstalled = TRUE
                Exit For
            End If
        Next
    End Function

    Function ReadRegistryValue(objRegistry, strType, intRegistryHive, strSubKeyName, sValueName)
        Select Case UCase(strType)
            Case "DWORD"
                objRegistry.GetDWORDValue intRegistryHive, strSubKeyName, sValueName, strValue
            Case "EXPANDEDSTRING"
                objRegistry.GetExpandedStringValue intRegistryHive, strSubKeyName, sValueName, strValue
            Case "MULTISTRING"
                objRegistry.GetMultiStringValue intRegistryHive, strSubKeyName, sValueName, strValue
            Case "STRING"
                objRegistry.GetStringValue intRegistryHive, strSubKeyName, sValueName, strValue
        End Select
       
        ReadRegistryValue = strValue
    End Function

    • Marked as answer by JuliusPIV Wednesday, September 7, 2011 4:57 PM
    Thursday, August 25, 2011 2:50 PM

All replies

  • Many possibilities here...

    I've been able to use the CopyProfile command to keep items that I've pinned to the Start Menu, but not the things that I've pinned to the Taskbar.

    However, you can define up to five things that you want everyone to have pinned to their Taskbar using the unattend.xml files...that's one way of getting things there, unfortunately, that does not get rid of the "default" MS items that are already there (IE, MediaPlayer, etc).

    Here's a way to do it using a script though:

    http://blogs.technet.com/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx

    You could in theory also configure these things using Group Policy Preferences.  There are two components to the Taskbar items, one is a registry key and the other is a file system shortcut.  The registry keys define what is there and in what order the items appear on the taskbar.  If you use GPP you could set both of those things up for all new profiles.

    However, I'm leaning towards using the script and something like Active Setup which will allow you to run a one-time command for every new user that logs in to a box.  That way I can remove the things I don't want and add in the ones that I do...

     


    Mike N.
    • Proposed as answer by Dale Qiao Wednesday, April 7, 2010 1:04 AM
    • Marked as answer by Dale Qiao Tuesday, April 13, 2010 1:37 AM
    Tuesday, April 6, 2010 7:40 PM
  • Within sysprep you can pin three items to the taskbar in the oobesystem pass under Shell Setup. After testing many different methods of pinning 5 items to the task bar I had little success with any of them and burned a lot of time. I have decided to leave the three items that Microsoft pins in the taskbar and just add three of my own (Word, Excel, and Powerpoint) using sysprep.

    Surely Microsoft should be able to come up with a better way of customizing the taskbar and start menu for users

    Tuesday, April 6, 2010 8:45 PM
  • Thanks for not only the link (Mike) but also the feedback (HendersonD).

    Using the information found in the link in Mikes post (either I used the link he posted or relentless searching proved useful and paid off!) , I created my own script to pin and unpin items on the Taskbar and Start Menu.  Also, after lots of digging around, I found the solution to getting rid of all the other items that appear on the Start Menu by default (displaySwitch, Remote Desktop, Getting Started etc).

    Although the script works, in that I get the desired outcome, I have a feeling I goofed on the code so its 'shot gunning' the stuff I don't want.  If anyone wants to help and provide feedback I'd love to hear it.

    Background:
    There were items on the Taskbar and Start Menu we wanted to customize.  The SIM allowed us to configure only a certain amount of shortcuts, far less than we needed/wanted.  So, it was back to inventing the wheel.
    The bulk of the items that appear on the Start Menu are stored in the registry.  (Yay!)
    However they're encrypted.  (Boo!)
    However, its only ROT13 so its easily defeated.  (Back to Yay again!)

    The script attempts to enumerate whats in "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist" converting it from ROT13 back to something useful so we can see what it is.  I could hard code what I don't want, but that would be too easy!  I wanted something portable this way I wouldn't have to worry about GUID's changing from machine to machine, or adding/removing things that sneak up on us in the future.  (Right Dale!?)

    Currently, as I hinted above, I think the script is removing all the values in there.  Its not a bad thing necessarily, but I would feel more comfortable if it behaved the way I want it to.  I suspect others might agree in that that I/We, the programmer, should be in control of our scripts; we should know what's happening not have a "Well, that is odd and can't be explained, but hey, the problem is fixed, right?" attitude.  (read: we should not just let whatever happens, happen.)
    Having said that, I suspect the problem lies within the logic of decrypting and checking the [decrypted] sting for a match against an array or comma separated string.  If someone wants to help with this great.  Otherwise, it *should* work as expected.

    This runs on a per-user basis at first sign-on:
    reg load HKU\DefUser "c:\Users\Default\NTUSER.DAT"
    reg add "HKU\DefUser\Software\Microsoft\Windows\CurrentVersion\Runonce" /v PinUnpin /t REG_EXPAND_SZ /d "%windir%\system32\wscript.exe path\to\pinunpin.vbs" /f
    reg unload HKU\DefUser

    Dale: I forgot about Active Setup, that might be more appropriate.

     

    '==========================================================================
    '
    ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2009
    '
    ' NAME: Pin & Unpin items to/from Start Menu & Taskabar
    '
    ' AUTHOR: JuliusPIV 
    ' DATE : 4/8/2010
    '
    ' COMMENT: 
    '
    '==========================================================================
    
    Dim sPath, sPinSMArray, sPinTBArray, sUnpinTBArray, PinItem
    Dim sMOW, sMOO, sFOX, sLN, sNuance, siMAN, sEXP, sWMP
    Const CSIDL_COMMON_PROGRAMS = &H17 
    Const CSIDL_PROGRAMS = &H2 
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oShell = CreateObject("Shell.Application") 
    Set wshshell = CreateObject("WScript.Shell")
    Set oAllUsersProgramsFolder = oShell.NameSpace(CSIDL_COMMON_PROGRAMS)
    
    sPath = oAllUsersProgramsFolder.Self.Path & "\"
    sMOW = "Microsoft Office Word 2007.lnk"
    sMOO = "Microsoft Office Outlook 2007.lnk"
    sFOX = "Mozilla Firefox.lnk"
    sLN = "Notes.lnk"
    sNuance = "Nuance PDF Professional 6\PDF Converter Professional.lnk"
    siMAN = "iManage.lnk"
    sEXP = wshshell.ExpandEnvironmentStrings("%WinDir%") & "\Explorer.exe"
    sWMP = wshshell.ExpandEnvironmentStrings("%ProgramFiles%") & "\Windows Media Player\wmplayer.exe"
    
    sPinSMArray = Array(sLN,sFOX,sMOO,sMOW,sNuance)
    sPinTBArray = Array(sMOO,sMOW,sFOX)
    sUnpinTBArray = Array(sEXP,sWMP)
    
    dim strScriptHost, output_echo
    strScriptHost = LCase(Wscript.FullName)
    If Right(strScriptHost, 11) = "wscript.exe" Then
     output_echo = False
    Else
     output_echo = True
    End If
    
    'Clearing out useless Start Menu icons
    EnumKeys "HKCU","Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist"
    
    WScript.Sleep(5000)
    
    Dim item
    For Each item In sPinSMArray
    	If Not fso.FileExists(sPath & item) Then
    		PinItem = False
    		debugecho "File, " & item & ", to pin does not exist in " & sPath & "."
    		debugecho "Please check the input and try again."
    		'WScript.quit
    	Else
    		PinSM(sPath & item)
    	End If
    Next
    
    For Each item In sPinTBArray
    	If Not fso.FileExists(sPath & item) Then
    		PinItem = False
    		debugecho "File, " & item & ", to pin does not exist in " & sPath & "."
    		debugecho "Please check the input and try again."
    		'WScript.quit
    	Else
    		PinTB(sPath & item)
    	End If
    Next
    
    For Each item In sUnpinTBArray
    	If Not fso.FileExists(item) Then
    		PinItem = False
    		debugecho "File, " & item & ", to unpin does not exist in " & sPath & "."
    		debugecho "Please check the input and try again."
    		'WScript.quit
    	Else
    		UnpinTB(item)
    	End If
    Next
    
    
    WScript.quit
    
    
    
    Function PinSM(shortcut)
    	On Error Resume Next
    	Set fso = CreateObject("Scripting.FileSystemObject")
    	Set oShell = CreateObject("Shell.Application") 
    	
    	sFolder = fso.GetParentFolderName(shortcut)
    	sFile = fso.GetFileName(shortcut)
    
    	debugecho "Pinning " & sFolder & "\" & sFile & " to Start Menu."
    	Err.Clear
    			
    	Set oFolder = oShell.NameSpace(sFolder)
    	Set oFolderItem = oFolder.ParseName(sFile)
    	Set colVerbs = oFolderItem.Verbs
    
    	For Each itemverb In oFolderItem.Verbs
    		If Replace(itemverb.name, "&", "") = "Pin to Start Menu" Then itemverb.DoIt
    	Next
    	On Error GoTo 0
    End Function
    
    Function PinTB(shortcut)
    	On Error Resume Next
    	Set fso = CreateObject("Scripting.FileSystemObject")
    	Set oShell = CreateObject("Shell.Application") 
    	
    	sFolder = fso.GetParentFolderName(shortcut)
    	sFile = fso.GetFileName(shortcut)
    
    	debugecho "Pinning " & sFolder & "\" & sFile & " to Taskbar."
    	Err.Clear
    			
    	Set oFolder = oShell.NameSpace(sFolder)
    	Set oFolderItem = oFolder.ParseName(sFile)
    	Set colVerbs = oFolderItem.Verbs
    	
    	For Each itemverb In oFolderItem.Verbs
    		If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt
    	Next
    	On Error GoTo 0
    End Function
    
    Function UnpinTB(shortcut)
    	On Error Resume Next
    	Set fso = CreateObject("Scripting.FileSystemObject")
    	Set oShell = CreateObject("Shell.Application") 
    	
    	sFolder = fso.GetParentFolderName(shortcut)
    	sFile = fso.GetFileName(shortcut)
    
    	debugecho "Unpinning " & sFolder & "\" & sFile & " from Taskbar."
    	Err.Clear
    			
    	Set oFolder = oShell.NameSpace(sFolder)
    	Set oFolderItem = oFolder.ParseName(sFile)
    	Set colVerbs = oFolderItem.Verbs
    	
    	For Each itemverb In oFolderItem.Verbs
    		If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt
    	Next
    	On Error GoTo 0
    End Function
    
    Function debugecho(msg)
    	if output_echo Then
    		wscript.echo msg
    	end if
    end Function
    
    Function EnumKeys(HKEY,Path)
    	Dim EKHKPath, GUIDPath, arrSubKeys, i
    	Select Case HKEY
    		Case "HKCU", "HKEY_CURRENT_USER"
    			Const HKCU = &H80000001
    			EKHKPath = HKCU
    		Case "HKLM", "HKEY_LOCAL_MACHINE"
    			Const HKLM = &H80000002
    			EKHKPath = HKLM
    		Case "HKU", "HKEY_USERS"
    			Const HKU = &H80000003
    			EKHKPath = HKU
    		Case "HKCR", "HKEY_CLASSES_ROOT"
    			Const HKCR = &H80000000
    			EKHKPath = HKCR
    		Case "HKCC", "HKEY_CURRENT_CONFIG"
    			Const HKCC = &H80000005
    			EKHKPath = HKCC
    		Case "HKDD", "HKEY_DYN_DAT"
    			Const HKDD = &H80000006
    			EKHKPath = HKDD
    		Case Else
    			WScript.Echo "ERROR: Invalid HKEY Type Specified (" & EKHKPath & ")"
    			WScript.echo "Please use HKCU, HKLM etc, or the long name equivalent."
    			WScript.Sleep(15000)
    			WScript.Quit
    	End Select
    	
    	Set objReg=GetObject("winmgmts:\\.\root\default:StdRegProv")
    	objReg.EnumKey EKHKPath, Path, arrSubKeys
    
    	if isarray(arrSubKeys) Then
    		For i=0 to UBound(arrSubKeys)
    			GUIDPath = Path & "\" & arrSubKeys(i) & "\Count"
    			'WScript.Echo "GuidPath: " & GUIDPath
    			EnumValues HKEY,GUIDPath
    			
     		Next
    	end If
    
    End Function
    
    Function EnumValues(HKEY,Path)
    	Dim EVHKPath, arrValueNames, arrValueTypes, i
    	
    	const REG_SZ = 1
    	const REG_EXPAND_SZ = 2
    	Const REG_BINARY = 3
    	Const REG_DWORD = 4
    	Const REG_MULTI_SZ = 7
     
    	Select Case HKEY
    		Case "HKCU", "HKEY_CURRENT_USER"
    			Const HKCU = &H80000001
    			EVHKPath = HKCU
    		Case "HKLM", "HKEY_LOCAL_MACHINE"
    			Const HKLM = &H80000002
    			EVHKPath = HKLM
    		Case "HKU", "HKEY_USERS"
    			Const HKU = &H80000003
    			EVHKPath = HKU
    		Case "HKCR", "HKEY_CLASSES_ROOT"
    			Const HKCR = &H80000000
    			EVHKPath = HKCR
    		Case "HKCC", "HKEY_CURRENT_CONFIG"
    			Const HKCC = &H80000005
    			EVHKPath = HKCC
    		Case "HKDD", "HKEY_DYN_DAT"
    			Const HKDD = &H80000006
    			EVHKPath = HKDD
    		Case Else
    			WScript.Echo "ERROR: Invalid HKEY Type Specified (" & EVHKPath & ")"
    			WScript.echo "Please use HKCU or the long name equivalent, HKEY_LOCAL_MACHINE."
    			WScript.Sleep(15000)
    			WScript.Quit
    	End Select
    
    	Set oReg=GetObject("winmgmts:\\.\root\default:StdRegProv")
    	oReg.EnumValues EVHKPath, Path, arrValueNames, arrValueTypes
    	
    	if isarray(arrValueNames) Then
    		For i=0 to UBound(arrValueNames)
    			'WScript.Echo "Unencrypted Value Name: " & arrValueNames(i)
    			arrValueNames(i) = Rot13Fixer(arrValueNames(i))
     		'WScript.Echo "Value Name: " & arrValueNames(i)
    ' #region Disabled code
    ' 	 	Select Case arrValueTypes(i)
    ' 		Case REG_SZ
    ' 		 		WScript.Echo "Data Type: String"
    ' 		 Case REG_EXPAND_SZ
    ' 				WScript.Echo "Data Type: Expanded String"
    ' 		 Case REG_BINARY
    ' 	 	 WScript.Echo "Data Type: Binary"
    ' 		Case REG_DWORD
    ' 					WScript.Echo "Data Type: DWORD"
    ' 		 Case REG_MULTI_SZ
    ' 					WScript.Echo "Data Type: Multi String"
    ' 			End Select
    ' #endregion
    		'WScript.Echo "this: " & HKEY & " " & Path & " " & arrValueNames(i)
    		FixStartMenu HKEY, Path, arrValueNames(i)
    		Next
    	End If
    End Function
    
    Function Rot13Fixer(sString)
    	Dim n, i, StringROT
    	For i=1 To Len(sString)
    		If Not IsNumeric(Mid(sString,i,1)) Then
    			individual_asc = Asc(Mid(sString,i,1))
    			'WScript.Echo "IASC: " & Chr(individual_asc) & " (" & individual_asc & ")"
    			If individual_asc >= 97 And individual_asc <=109 Then
    				individual_asc = individual_asc +13
    				'WScript.Echo "IASC+13.1: " & Chr(individual_asc) & " (" & individual_asc & ")"
    			Else
    				If individual_asc >= 110 And individual_asc <= 122 Then
    					individual_asc = individual_asc -13
    					'WScript.Echo "IASC-13.1: " & Chr(individual_asc) & " (" & individual_asc & ")"
    				Else
    					If individual_asc >= 65 And individual_asc <= 77 Then
    						individual_asc = individual_asc +13
    						'WScript.Echo "IASC+13.2: " & Chr(individual_asc) & " (" & individual_asc & ")"
    					Else
    						If individual_asc >= 78 And individual_asc <= 90 Then
    							individual_asc = individual_asc -13
    							'WScript.Echo "IASC-13.2: " & Chr(individual_asc) & " (" & individual_asc & ")"
    						End If
    					End If
    				End If
    			End If
    			StringROT = StringROT + Chr(individual_asc)
    		Else StringROT = StringROT + Mid(sString,i,1)
    		End If
    		'WScript.Echo StringROT
    	Next
    	Rot13Fixer = StringROT
    End Function
    
    Function FixStartMenu(HKEY, Path, ValueName)
    	Dim FSMPath, encValueName, arrDeleteApps
    	Select Case HKEY
    		Case "HKCU", "HKEY_CURRENT_USER"
    			Const HKCU = &H80000001
    			FSMPath = HKCU
    		Case "HKLM", "HKEY_LOCAL_MACHINE"
    			Const HKLM = &H80000002
    			FSMPath = HKLM
    		Case "HKU", "HKEY_USERS"
    			Const HKU = &H80000003
    			FSMPath = HKU
    		Case "HKCR", "HKEY_CLASSES_ROOT"
    			Const HKCR = &H80000000
    			FSMPath = HKCR
    		Case "HKCC", "HKEY_CURRENT_CONFIG"
    			Const HKCC = &H80000005
    			FSMPath = HKCC
    		Case "HKDD", "HKEY_DYN_DAT"
    			Const HKDD = &H80000006
    			FSMPath = HKDD
    		Case Else
    			WScript.Echo "ERROR: Invalid HKEY Type Specified (" & EVHKPath & ")"
    			WScript.echo "Please use HKCU or the long name equivalent, HKEY_LOCAL_MACHINE."
    			WScript.Sleep(15000)
    			WScript.Quit
    	End Select
    	
    	arrDeleteApps = Array("microsoft.windows.gettingstarted","displayswitch.exe","microsoft.windows.remotedesktop","microsoft.windows.stickynotes","snippingtool.exe" &_
    		"calc.exe","mspaint.exe","xpsrchvw.exe","wfs.exe","magnify.exe","welcome center.lnk","displayswitch.lnk","remote desktop connection.lnk","sticky notes.lnk" &_
    		"snipping tool.lnk","calculator.lnk","paint.lnk","xps viewer.lnk","windows fax and scan.lnk","magnify.lnk")
    
    	For i=0 To UBound(arrDeleteApps)		
    		If (instr(1,lcase(ValueName), lcase(deleteapps),1) > 0) Then
    			'WScript.Echo "hit"
    			encValueName = Rot13Fixer(ValueName)
    			Set oReg=GetObject("winmgmts:\\.\root\default:StdRegProv")
     			oReg.DeleteValue HKCU,Path,encValueName
     		End If
     	Next
    
    End Function
    
    

     

    • Marked as answer by JuliusPIV Friday, May 28, 2010 11:12 AM
    Friday, May 28, 2010 11:08 AM
  • Wow!  Thanks MS for making this so complicated.   Okay.  My apologies.

    So how much of this do I need if I just want to clear the start menu of all the unwanted junk?  

    Does the following go in the setcomplete.cmd file?

    reg load HKU\DefUser "c:\Users\Default\NTUSER.DAT"
    reg add "HKU\DefUser\Software\Microsoft\Windows\CurrentVersion\Runonce" /v PinUnpin /t REG_EXPAND_SZ /d "%windir%\system32\wscript.exe path\to\pinunpin.vbs" /f
    reg unload HKU\DefUser

    Thanks for any assistance and thanks JuliusPIV for this example.

    • Proposed as answer by Eunox Friday, October 5, 2012 2:55 PM
    • Unproposed as answer by Eunox Friday, October 5, 2012 2:55 PM
    Monday, December 13, 2010 4:32 PM
  • Thanks for the script. I implemented using GPP and it works great.
    Wednesday, March 2, 2011 5:07 AM
  • This is a great post and I have found it incredibly useful!  I see that you have coded for removing unwanted applications from the most recently opened list, but have you figured out how to pre-populate this list as well?  I would like to set up the default to have what we feel are the most popular programs for our users but we don't want to pin them.  I have tried the manual approach of setting it up exactly as I want and export all keys and values under HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\, then import these keys at first logon but it doesn't work.  Any advice would be greatly appreciated.

    Thanks!

    Thursday, March 17, 2011 10:18 AM
  • Hey Paul.Jones

    Sorry for the delay.  I'm a little surprised to read this.  Like you I figured

    "If clearing the items in "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist" results in a clean Start Menu (and Start Menu > All Programs? I forget now...), presumably anything added to that location will add to the Start Menu."

    When you added these shortcuts back in, did you add them 'unencrypted' or were they [ROT13] 'encrypted'?

     

    Might be wise to start a new thread - this one's getting long in the tooth and, although related, slightly different!

    Monday, April 25, 2011 6:49 PM
  • That's why it is doing every single entry.

    If (instr(1,lcase(ValueName), lcase(deleteapps),1) > 0) Then

    deleteapps is not a defined variable, so it has a value of "". When using InStr, if Len(string2) = 0 then InStr will return Start (which is 1 by default and in your case as well. The line should be (you also don't need to convert it to lcase because you are doing a text comparison:

    If (instr(1, ValueName, arrDeleteApps(i), 1) > 0) Then

     

    Another error in your script is:

    	arrDeleteApps = Array("microsoft.windows.gettingstarted","displayswitch.exe","microsoft.windows.remotedesktop","microsoft.windows.stickynotes","snippingtool.exe" &_
    		"calc.exe","mspaint.exe","xpsrchvw.exe","wfs.exe","magnify.exe","welcome center.lnk","displayswitch.lnk","remote desktop connection.lnk","sticky notes.lnk" &_
    		"snipping tool.lnk","calculator.lnk","paint.lnk","xps viewer.lnk","windows fax and scan.lnk","magnify.lnk")

     

    You don't use & _  to change line in an array, as that just appends the string. Effectively you are doing "snippingtool.exe" & "calc.exe" which will generate a string of "snippingtool.execalc.exe"

     

    Instead, your array should be like this:

    	arrDeleteApps = Array("microsoft.windows.gettingstarted","displayswitch.exe","microsoft.windows.remotedesktop","microsoft.windows.stickynotes","snippingtool.exe", _
    		"calc.exe","mspaint.exe","xpsrchvw.exe","wfs.exe","magnify.exe","welcome center.lnk","displayswitch.lnk","remote desktop connection.lnk","sticky notes.lnk", _
    		"snipping tool.lnk","calculator.lnk","paint.lnk","xps viewer.lnk","windows fax and scan.lnk","magnify.lnk")

     

     


    Thursday, August 25, 2011 2:45 PM
  • Also, here's an optimized version of your script (code is a little bit tidier and functions have been optimized to avoid calling the same function too many times).

    Last thing, I noticed that just removing the .lnk files removes the application from the start menu. I think that the items with the .exe extension is just so that Windows knows how many times a certain application was used so that it can be pushed up/down the list on the start menu. Because of that, I am not touching the .exe files.

     

    '=-=-=-=-=-=-=-=-=-=-=-=-=
    '           CONSTS
    '=-=-=-=-=-=-=-=-=-=-=-=-=
    Const HKEY_CLASSES_ROOT     = &H80000000
    Const HKEY_CURRENT_USER     = &H80000001
    Const HKEY_LOCAL_MACHINE     = &H80000002
    Const HKEY_USERS             = &H80000003
    Const HKEY_CURRENT_CONFIG     = &H80000005

    Const CSIDL_COMMON_PROGRAMS    = &H17
    Const CSIDL_PROGRAMS        = &H2

    '=-=-=-=-=-=-=-=-=-=-=-=-=
    '          OBJECTS
    '=-=-=-=-=-=-=-=-=-=-=-=-=
    Set objRegistry            = GetObject("winmgmts:\\.\root\default:StdRegProv")
    Set objFSO                = CreateObject("Scripting.FileSystemObject")
    Set objApplication        = CreateObject("Shell.Application")
    Set objAllUsersPrograms    = objApplication.NameSpace(CSIDL_COMMON_PROGRAMS)
    Set objUserPrograms        = objApplication.NameSpace(CSIDL_PROGRAMS)

    '=-=-=-=-=-=-=-=-=-=-=-=-=
    '          VARIABLES
    '=-=-=-=-=-=-=-=-=-=-=-=-=
    Dim arrSubValues, arrDeleteApps, arrPinApps, strAllUsersProgramsPath

    strAllUsersProgramsPath    = objAllUsersPrograms.Self.Path & "\"
    strUserProgramsPath        = objUserPrograms.Self.Path & "\"
    arrDeleteApps            = Array("displayswitch.lnk", "remote desktop connection.lnk", "sticky notes.lnk", "snipping tool.lnk", "calculator.lnk", "paint.lnk", "xps viewer.lnk", "windows fax and scan.lnk")


    Call Main

    Sub Main()
        DeleteStartMenuApps HKEY_CURRENT_USER, "", arrDeleteApps

        DoVerb "Pin to Start Menu", strUserProgramsPath & "Internet Explorer.lnk"
       
        'Get the version of Office installed, so that we can pin it to the start menu
        If IsProgramInstalled(objRegistry, "Microsoft Office Enterprise 2007") = TRUE Then
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Office Word 2007.lnk"
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Office Excel 2007.lnk"
        Else   
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Word 2010.lnk"
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Excel 2010.lnk"
        End If
    End Sub


    '=-=-=-=-=-=-=-=-=-=-=-=-=
    '     FUNCTIONS AND SUBS
    '=-=-=-=-=-=-=-=-=-=-=-=-=
    Function DoVerb(strVerb, strPath)
        On Error Resume Next
            strFolder    = objFSO.GetParentFolderName(strPath)
            strFile        = objFSO.GetFileName(strPath)
           
            Set objFolder        = objApplication.NameSpace(strFolder)
            Set objFolderItem    = objFolder.ParseName(strFile)
           
            For Each ItemVerb In objFolderItem.Verbs
                If StrComp(Replace(ItemVerb.Name, "&", ""), strVerb, vbTextCompare) = 0 Then
                    ItemVerb.DoIt
                    Exit Function
                End If
            Next
        On Error Goto 0
    End Function

    Sub DeleteStartMenuApps(hDefKey, sSubKeyUser, arrDeleteApps)
        If Len(sSubKeyUser) > 0 Then
            sSubKeyName = sSubKeyUser & "\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist"
        Else
            sSubKeyName = "Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist"
        End If   
       
        objRegistry.EnumKey hDefKey, sSubKeyName, arrSubKeys
       
        If IsArray(arrSubKeys) Then
            For i = 0 to UBound(arrSubKeys)
                sTempSubKeyName = sSubKeyName & "\" & arrSubKeys(i) & "\Count"
                objRegistry.EnumValues hDefKey, sTempSubKeyName, arrSubValues
            
                If IsArray(arrSubValues) Then
                    For m = 0 to UBound(arrSubValues)
                        For n = 0 to UBound(arrDeleteApps)
                            If InStr(UCase(RunROT13(arrSubValues(m))), UCase(arrDeleteApps(n))) > 0 Then
                                objRegistry.DeleteValue hDefKey, sTempSubKeyName, arrSubValues(m)
                            End If
                        Next
                    Next
                End If
            Next
        End If
    End Sub


    Function RunROT13(strInput)
        For i = 1 to Len(strInput)
            iChr = Asc(Mid(strInput, i, 1))
            If (iChr >= 65 and iChr <= 77) Or (iChr >= 97 and iChr <= 109) Then
                strOutput = strOutput & Chr(iChr +13)
            ElseIf (iChr >= 78 and iChr <= 90) Or (iChr >= 110 and iChr <= 122) Then
                strOutput = strOutput & Chr(iChr -13)
            Else
                strOutput = strOutput & Chr(iChr)
            End If
        Next

        RunROT13 = strOutput
    End Function

    Function IsProgramInstalled(objRegistry, strProgramDisplayName)
        intRegistryHive    = HKEY_LOCAL_MACHINE
        strRegistryKey    = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
       
        objRegistry.EnumKey intRegistryHive, strRegistryKey, arrSubkeys
       
        IsProgramInstalled = FALSE
       
        For Each strSubkey In arrSubkeys
            strDisplayName = ReadRegistryValue(objRegistry, "STRING", intRegistryHive, strRegistryKey & "\" & strSubkey, "DisplayName")
           
            If UCase(strDisplayName) = UCase(strProgramDisplayName) Then
                IsProgramInstalled = TRUE
                Exit For
            End If
        Next
    End Function

    Function ReadRegistryValue(objRegistry, strType, intRegistryHive, strSubKeyName, sValueName)
        Select Case UCase(strType)
            Case "DWORD"
                objRegistry.GetDWORDValue intRegistryHive, strSubKeyName, sValueName, strValue
            Case "EXPANDEDSTRING"
                objRegistry.GetExpandedStringValue intRegistryHive, strSubKeyName, sValueName, strValue
            Case "MULTISTRING"
                objRegistry.GetMultiStringValue intRegistryHive, strSubKeyName, sValueName, strValue
            Case "STRING"
                objRegistry.GetStringValue intRegistryHive, strSubKeyName, sValueName, strValue
        End Select
       
        ReadRegistryValue = strValue
    End Function

    • Marked as answer by JuliusPIV Wednesday, September 7, 2011 4:57 PM
    Thursday, August 25, 2011 2:50 PM
  • Wow, this is all I do:

     

    reg load HKU\myuser c:\users\default\ntuser.dat

    rem has [HKEY_USERS\myuser\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband]
    reg import taskband.reg

    reg unload HKU\myuser

    copy /y *.lnk "C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\"

     

    Thursday, August 25, 2011 4:56 PM
  • Wow, this is all I do:

     

    reg load HKU\myuser c:\users\default\ntuser.dat

    rem has [HKEY_USERS\myuser\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband]
    reg import taskband.reg

    reg unload HKU\myuser

    copy /y *.lnk "C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\"

     


    batch files are antique, non-flexible, rudimentary and lack functionality. Also just copying a .lnk to C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\ doesn't pin an item.

     

    You are importing a static reg file that already contains all of your changes. I created a script that adapts to the needs of the user. If you show us your reg file no one will have any idea what you are actually removing on each individual line just by looking at it - probably not even yourself. You know what the end result is, sure, but it's not the same.

     

    I like flexibility and not assuming things. You assume Windows is english version and installed on the C: partition for example. I'm a contractor, I create platforms that can be used for all my clients, not a static reg file that only suits the needs of a particular organization.

    Friday, August 26, 2011 10:52 AM
  • The .lnk files plus the registry entries do indeed work.  Just fyi.


    By the way sysprep supports up to 3 taskbar pins, but I haven't use that feature.

     

    Friday, August 26, 2011 2:51 PM
  • Also just copying a .lnk to C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\ doesn't pin an item.

    Sysprep allows for up to 3 taskbar pins, yes, but does not allow you to modify the start menu most used list nor to actually pin anything to the start menu itself, which is often what people want most.

     

    In the end of the day, more functionality than what Microsoft implemented was required, and people found a way around it. Some do bat files and reg files, some do vbs files - let's stop this argument.

     

    Only two reasons why I posted on such an old thread was because:

     

    1) I came across the same problem as the OP and ended up here whilst looking for a solution;

    2) The OP suggested a scripted solution but also raised some questions about why it was behaving the way it was. I cleaned the script up a bit and answered those questions.

    Thursday, September 1, 2011 9:55 AM
  • cogumel0: thanks for the response!  Myself and many, many others, I'm sure, will greatly benefit from your input.

    I also appreciate the constructive criticism and help correcting my script!  I was, at the time, very new to VB scripting.  Although I've learned a significant amount since then, I've still got a lot to learn!  As time permits, which is usually when the need arises, I fix my old scripts but I haven't circled back to this one.

    This is huge and thanks so much for taking the time to respond!

    Wednesday, September 7, 2011 4:53 PM
  • Dear cogumel0,

    I loved your organised script can you please spare time and make a script for the following to be pinned to taskbar and delete all shorcuts from the start menu. This to be loaded to default user....

    "C:\Program Files\Internet Explorer\iexplore.exe"
    "C:\Program Files\Mozilla Firefox\firefox.exe"
    "C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe"
    "C:\Program Files\Google\Picasa3\Picasa3.exe"
    "C:\Program Files\TeamViewer\Version6\TeamViewer.exe"
    "C:\Program Files\Nero\Nero Burning ROM\nero.exe"

    Office 2010 Word, Excel and outlook.

    Regards,

    nitin...

     

     

    Saturday, January 7, 2012 3:13 PM
  • Hello,

    I did follwing modifications to get it running on a German/Deutsch Windows 7 SP1 64BIT Version. (Highlited FAT)

    ********************************

    Function IsProgramInstalled(objRegistry, strProgramDisplayName)
        intRegistryHive    = HKEY_LOCAL_MACHINE
        strRegistryKey    = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"

    ********************************

        'Get the version of Office installed, so that we can pin it to the start menu
        If IsProgramInstalled(objRegistry, "Microsoft Office Enterprise 2007") = TRUE Then
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Office Word 2007.lnk"
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Office Excel 2007.lnk"
            DoVerb "Pin to Start Menu", strAllUsersProgramsPath & "Microsoft Office\Microsoft Office Outlook 2007.lnk"
        Else   
            DoVerb "An Taskleiste anheften", strAllUsersProgramsPath & "Microsoft Office\Microsoft Word 2010.lnk"
            DoVerb "An Taskleiste anheften", strAllUsersProgramsPath & "Microsoft Office\Microsoft Excel 2010.lnk"
            DoVerb "An Taskleiste anheften", strAllUsersProgramsPath & "Microsoft Office\Microsoft Outlook 2010.lnk"
        End If
    End Sub

    DEUTSCH
    '"An Startmenü anheften"
    '"An Taskleiste anheften"
    ENGLISCH
    '"Pin to Start Menu"

    Tuesday, April 24, 2012 10:53 AM
  • Sorry guys,

    This topic gives me the creeps. Windows 7 should make things easyer, and I do not want to go back to scripting and other ancient programming.

    005056AC505A

    Microsoft should solve this in a decent way without any "hacking"

    in the classroom (400 pc's) I want to tune 1 pc and push that Startmenu/usersettings to every installation.

    So  not running a script, but just plain and simple a "mandatory" startmenu and settings

    They should enable the "Copy Profile"  buttom and solve the issues.

    For those who are not familiar with these scripts .

    1) login as a user (lets say Dummy)

    2) "tune" his settings.

    3) Download (hacktool) "enabler"

    4) Copy the profile from "Dummy" to "default user"

    5) regedit --> Load hive and choose ntuser.dat from default user in "HKU" 

    6) search for "Dummy" and delete all the keys where you find "dummy"

    7) unload the hive

    8) reboot the system (do not logof!!)

    Ghost or provision that tuned image to all PC's and your done.

    However . .

    Microsoft make things easyer not complicated . .


    Tuesday, August 7, 2012 9:50 AM
  • Sorry guys,

    This topic gives me the creeps. Windows 7 should make things easyer, and I do not want to go back to scripting and other ancient programming.

    005056AC505A

    Microsoft should solve this in a decent way without any "hacking"

    in the classroom (400 pc's) I want to tune 1 pc and push that Startmenu/usersettings to every installation.

    So  not running a script, but just plain and simple a "mandatory" startmenu and settings

    They should enable the "Copy Profile"  buttom and solve the issues.

    For those who are not familiar with these scripts .

    1) login as a user (lets say Dummy)

    2) "tune" his settings.

    3) Download (hacktool) "enabler"

    4) Copy the profile from "Dummy" to "default user"

    5) regedit --> Load hive and choose ntuser.dat from default user in "HKU" 

    6) search for "Dummy" and delete all the keys where you find "dummy"

    7) unload the hive

    8) reboot the system (do not logof!!)

    Ghost or provision that tuned image to all PC's and your done.

    However . .

    Microsoft make things easyer not complicated . .


    First of all apologies for what follows but you caught me on a bad day...

    I sort of stopped reading when you suggested logging in as a user and using Ghost at the end.

    You complain about Microsoft making things more difficult when in fact you're the one making things more difficult on yourself. Nowadays no one uses Ghost or has to login to a PC (in fact logging in is not advisable at all since you are "contaminating" the end product).

    If you don't have SCCM use MDT. In a nutshell, amongst other things, it allows you to run scripts as system without having to ever login or manually starting a script run.

    However, in your particular case, it sounds like the matter can be solved in an even easier way. Windows 7 allows you to have a domain profile that applies to all users (assuming they don't have a profile on the machine yet which is what you are talking about as well).

    See: http://support.microsoft.com/kb/973289 for more information

    Tuesday, February 26, 2013 5:13 PM
  • Everyone: Thanks for adding to the thread with things that work for you, suggestions, questions etc - all great stuff.

    cogumel0: Again many thanks for following the thread and sharing your expertise!  I'm certain you'll have something constructive to add to the script below.


    Time keeps ticking, and new needs arise.  We've introduced new applications, new versions of existing applications & even removed applications.  As such, the need to pin & unpin had reared its ugly little head again.  Some time ago I created subroutines to pin to & unpin from both the startmenu & taskbar, then re-used that code to to build a script that could accept arguments so I could call it from another install.  So far, it seems to be working brilliantly.

    I hope this is of use to someone.


    The idea here is that you would call the script from either another vbscript or a batch file as so:

      pinunpin.vbs [pin | unpin] [PATH_TO_FILE.EXE | PATH_TO_FILE.LNK]
      pinunpin.vbs pin taskbar "C:\Program Files\Mozilla Firefox\firefox.exe"
      pinunpin.vbs pin startmenu "C:\Program Files\TeamViewer\Version6\TeamViewer.exe"
      pinunpin.vbs unpin taskbar "C:\Program Files\Internet Explorer\iexplore.exe"
      pinunpin.vbs unpin startmenu "C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe"

    Alternatively, just use the subroutines and call them as such:

      PinToStartMenu [PATH_TO_FILE.EXE | PATH_TO_FILE.LNK]
      PinToTaskBar  [PATH_TO_FILE.EXE | PATH_TO_FILE.LNK]
      UnpinFromStartMenu  [PATH_TO_FILE.EXE | PATH_TO_FILE.LNK]
      UnpinFromTaskBar  [PATH_TO_FILE.EXE | PATH_TO_FILE.LNK]


    Dim iArgCount
    
    iArgCount = WScript.Arguments.Count
    If (iArgCount <> 3) Then
    	ShowUsage
    End If
    
    Dim sAction,sSMorTB,sFilePath
    sAction = LCase(WScript.Arguments.Item(0))
    sSMorTB = LCase(WScript.Arguments.Item(1))
    sFilePath = LCase(WScript.Arguments.Item(2))
    
    If (sAction <> "pin") And (sAction <> "unpin") Then
    	WScript.Echo "Error: Invalid Action: '" & sAction & "'"
    	ShowUsage
    End If
    
    If (sSMorTB <> "startmenu") And (sSMorTB <> "taskbar") Then
    	WScript.Echo "Error: Invalid Location: '" & sSMorTB & "'"
    	ShowUsage
    End If
    
    If (sAction = "pin") And (sSMorTB = "startmenu") Then PinToStartMenu sFilePath
    If (sAction = "pin") And (sSMorTB = "taskbar") Then PinToTaskBar sFilePath
    If (sAction = "unpin") And (sSMorTB = "startmenu") Then UnpinFromStartMenu sFilePath
    If (sAction = "unpin") And (sSMorTB = "taskbar") Then UnpinFromTaskBar sFilePath
    
    
    WScript.Quit		
    
    Sub ShowUsage
    	WScript.Echo "Usage:  " & WScript.ScriptName & " [PIN|UNPIN] [STARTMENU|TASKBAR] File"
    	WScript.Echo vbTab & WScript.ScriptName & " PIN startmenu C:\apps\tools\wmopener.exe"
    	WScript.Echo vbTab & WScript.ScriptName & " unpin TASKBAR ""C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Mozilla Firefox.lnk"""
    	WScript.Quit
    End Sub
    
    Sub PinToStartMenu(Required_Path_To_Item)
    	' See
    	' http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx?PageIndex=3
    	Const CSIDL_COMMON_PROGRAMS = &H17 
    	Const CSIDL_PROGRAMS = &H2 
    	
    	Dim s_oFSO, s_oShell, s_oAllUsersProgramsFolder
    	Dim s_oFolder, s_oFolderItem, s_colVerbs, s_oVerb
    	Dim s_FullItemPath, s_sItemFolder, s_sItemName, s_sAllUsersProgramsPath
    
    	Set s_oFSO = CreateObject("Scripting.FileSystemObject")
    	Set s_oShell = CreateObject("Shell.Application")
    	
    	s_FullItemPath = Required_Path_To_Item
    	
    	If Not (s_oFSO.FileExists(s_FullItemPath)) Then
    		WScript.Echo "Error Pinning File '" & s_FullItemPath & "' to Start Menu: File Does Not Exist!"
    		Exit Sub
    	End If
    	
    	s_sItemFolder = s_oFSO.GetParentFolderName(s_FullItemPath)
    	s_sItemName = s_oFSO.GetFileName(s_FullItemPath)
    
    	Set s_oFolder = s_oShell.Namespace(s_sItemFolder) 
    	Set s_oFolderItem = s_oFolder.ParseName(s_sItemName) 
    	Set s_colVerbs = s_oFolderItem.Verbs 
    
    	For Each s_oVerb in s_colVerbs 
    		If Replace(s_oVerb.name, "&", "") = "Pin to Start Menu" Then
    			WScript.Echo "Pinning '" & s_FullItemPath & "' to Start Menu"
    			's_oVerb.DoIt
    		ElseIf Replace(s_oVerb.name, "&", "") = "Unpin from Start Menu" Then
    			WScript.Echo "Error: Item '" & s_FullItemPath & "' is Already Pinned to Start Menu"
    		End If
    	Next
    End Sub
    
    Sub PinToTaskBar(Required_Path_To_Item)
    	' See
    	' http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx?PageIndex=3
    	Const CSIDL_COMMON_PROGRAMS = &H17 
    	Const CSIDL_PROGRAMS = &H2 
    	
    	Dim s_oFSO, s_oShell, s_oAllUsersProgramsFolder
    	Dim s_oFolder, s_oFolderItem, s_colVerbs, s_oVerb
    	Dim s_FullItemPath, s_sItemFolder, s_sItemName, s_sAllUsersProgramsPath
    
    	Set s_oFSO = CreateObject("Scripting.FileSystemObject")
    	Set s_oShell = CreateObject("Shell.Application")
    	
    	s_FullItemPath = Required_Path_To_Item
    	
    	If Not (s_oFSO.FileExists(s_FullItemPath)) Then
    		WScript.Echo "Error Pinning File '" & s_FullItemPath & "' to TaskBar: File Does Not Exist!"
    		Exit Sub
    	End If
    	
    	s_sItemFolder = s_oFSO.GetParentFolderName(s_FullItemPath)
    	s_sItemName = s_oFSO.GetFileName(s_FullItemPath)
    
    	Set s_oFolder = s_oShell.Namespace(s_sItemFolder) 
    	Set s_oFolderItem = s_oFolder.ParseName(s_sItemName) 
    	Set s_colVerbs = s_oFolderItem.Verbs 
    
    	For Each s_oVerb in s_colVerbs 
    		If Replace(s_oVerb.name, "&", "") = "Pin to Taskbar" Then
    			WScript.Echo "Pinning '" & s_FullItemPath & "' to Taskbar"
    			's_oVerb.DoIt
    		ElseIf Replace(s_oVerb.name, "&", "") = "Unpin from Taskbar" Then
    			WScript.Echo "Error: Item '" & s_FullItemPath & "' is Already Pinned to Taskbar"
    		End if
    	Next
    End Sub
    
    Sub UnpinFromStartMenu(Required_Path_To_Item)
    	' See
    	' http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx?PageIndex=3
    	Const CSIDL_COMMON_PROGRAMS = &H17 
    	Const CSIDL_PROGRAMS = &H2 
    	
    	Dim s_oFSO, s_oShell, s_oAllUsersProgramsFolder
    	Dim s_oFolder, s_oFolderItem, s_colVerbs, s_oVerb
    	Dim s_FullItemPath, s_sItemFolder, s_sItemName, s_sAllUsersProgramsPath
    
    	Set s_oFSO = CreateObject("Scripting.FileSystemObject")
    	Set s_oShell = CreateObject("Shell.Application")
    	
    	s_FullItemPath = Required_Path_To_Item
    	
    	If Not (s_oFSO.FileExists(s_FullItemPath)) Then
    		WScript.Echo "Error Unpinning File '" & s_FullItemPath & "' From Start Menu: File Does Not Exist!"
    		Exit Sub
    	End If
    	
    	s_sItemFolder = s_oFSO.GetParentFolderName(s_FullItemPath)
    	s_sItemName = s_oFSO.GetFileName(s_FullItemPath)
    
    	Set s_oFolder = s_oShell.Namespace(s_sItemFolder) 
    	Set s_oFolderItem = s_oFolder.ParseName(s_sItemName) 
    	Set s_colVerbs = s_oFolderItem.Verbs 
    
    	For Each s_oVerb in s_colVerbs 
    		If Replace(s_oVerb.name, "&", "") = "Unpin from Start Menu" Then
    			WScript.Echo "Unpinning '" & s_FullItemPath & "' From Start Menu"
    			's_oVerb.DoIt
    		ElseIf Replace(s_oVerb.name, "&", "") = "Pin to Start Menu" Then
    			WScript.Echo "Error: Item '" & s_FullItemPath & "' is Not Pinned to Start Menu"
    		End if
    	Next
    End Sub
    
    Sub UnpinFromTaskBar(Required_Path_To_Item)
    	' See
    	' http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx?PageIndex=3
    	Const CSIDL_COMMON_PROGRAMS = &H17 
    	Const CSIDL_PROGRAMS = &H2 
    	
    	Dim s_oFSO, s_oShell, s_oAllUsersProgramsFolder
    	Dim s_oFolder, s_oFolderItem, s_colVerbs, s_oVerb
    	Dim s_FullItemPath, s_sItemFolder, s_sItemName, s_sAllUsersProgramsPath
    
    	Set s_oFSO = CreateObject("Scripting.FileSystemObject")
    	Set s_oShell = CreateObject("Shell.Application")
    	
    	s_FullItemPath = Required_Path_To_Item
    	
    	If Not (s_oFSO.FileExists(s_FullItemPath)) Then
    		WScript.Echo "Error Unpinning File '" & s_FullItemPath & "' from Taskbar: File Does Not Exist!"
    		Exit Sub
    	End If
    	
    	s_sItemFolder = s_oFSO.GetParentFolderName(s_FullItemPath)
    	s_sItemName = s_oFSO.GetFileName(s_FullItemPath)
    
    	Set s_oFolder = s_oShell.Namespace(s_sItemFolder) 
    	Set s_oFolderItem = s_oFolder.ParseName(s_sItemName) 
    	Set s_colVerbs = s_oFolderItem.Verbs 
    
    	For Each s_oVerb in s_colVerbs 
    		If Replace(s_oVerb.name, "&", "") = "Unpin from Taskbar" Then
    			WScript.Echo "Unpinning '" & s_FullItemPath & "' from Taskbar"
    			's_oVerb.DoIt
    		ElseIf Replace(s_oVerb.name, "&", "") = "Pin to Taskbar" Then
    			WScript.Echo "Error: Item '" & s_FullItemPath & "' is Not Pinned to Taskbar"
    		End if
    	Next
    End Sub


    While I'm certain there's more to improve on, one thing I wanted to do is detect whether its being called via wscript (instead of cscript) and to suppress the wscript.echo popups if its called via wscript.  But its just easier to comment out the wscript.echo lines. :)


    • Edited by JuliusPIV Wednesday, March 27, 2013 4:38 PM
    Wednesday, March 27, 2013 4:31 PM