[SOLVED] How to Pin to Start Menu/Task Bar for Default User
-
Tuesday, April 06, 2010 6:25 PM
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?
(This is for a Win 7 Enterprise Deployment)
All Replies
-
Tuesday, April 06, 2010 7:48 PM
Hi JuliusPIV,
Thus works for me http://support.microsoft.com/default.aspx/kb/168475?p=1 for Windows XP Pro.
After I think I have the 'test' user profile correct I try logging in as a user that has never logged in on this specific PC before to see if all customizations were correct. If all goes well with that then I reboot and login as a local administrator and delete all user profiles but of course not the 'Default User' or 'administrator'. This does work when a system has been sysprepped. Remember though to not look for the customizations in the local admin account or any account that existed before the 'Default ser' profile was customized. The customizations will only apply to new users.
-
Friday, May 28, 2010 11:21 AM
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\DefUserDale: 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
-
Friday, May 28, 2010 12:08 PM
Awesome! ... However it looks like it's missing an "End Function" on the last line (for the FixStartMenu Function), or was the script truncated?
/ Johan
-
Thursday, June 03, 2010 9:20 AM
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?
(This is for a Win 7 Enterprise Deployment)
I know I'm answering a solved issue, just wanted to share (and get critique) on my take on the issue. Here's what I do:- Set the policy "Clear the recent programs list for new users".
- Load the default user hive in my TS with a run command line task:
REG LOAD HKU\Default C:\Users\Default\NTUSER.DAT - Add a new value to the default user RunOnce key (REG ADD HKU\Default\Software\Microsoft\Windows\CurrentVersion\RunOnce), a vbscript that's copied to the computer
I actually added the policy above locally and not via GPO, it's at HKU\Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer. - Unload the default user hive with another run command line task:
REG UNLOAD HKU\Default
The vbscript in the RunOnce key uses Shell.Application to execute the verbs "Pin to Start Menu" and "Pin to Taskbar" on shortcuts in the start menu in the order I want them.
-Anders
-
Friday, June 11, 2010 10:16 AM
Thanks for sharing Anders! I've not tried that specific method, but if it works it works. I found that even when I had set CopyProfile to True and pinned items under the account I was using to setup the default user profile, those items would not stick. Your solution however may work post-sysprep.
If it works or you find another way let us know!
-
Friday, June 11, 2010 2:54 PM
The above works. I prefer to make as many changes as possible post-sysprep. The stuff above is run in the task sequence as steps - I don't want anything unautomated at all in my deployment prep.
The only issue is that I'm not sure messing with the default profile is supported. Modifying a hive should be risk free though - as opposed to replacing the default profile post-sysprep.
IMO it's way better to script default user changes via runonce than manually messing with the profile.
-Anders
-
Thursday, July 08, 2010 9:56 PM
I know I'm answering a solved issue, just wanted to share (and get critique) on my take on the issue. Here's what I do:
- Set the policy "Clear the recent programs list for new users".
- Load the default user hive in my TS with a run command line task:
REG LOAD HKU\Default C:\Users\Default\NTUSER.DAT - Add a new value to the default user RunOnce key (REG ADD HKU\Default\Software\Microsoft\Windows\CurrentVersion\RunOnce), a vbscript that's copied to the computer
I actually added the policy above locally and not via GPO, it's at HKU\Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer. - Unload the default user hive with another run command line task:
REG UNLOAD HKU\Default
The vbscript in the RunOnce key uses Shell.Application to execute the verbs "Pin to Start Menu" and "Pin to Taskbar" on shortcuts in the start menu in the order I want them.
-Anders
Hi, can you post the code you used to run the script when a new user logs in? I downloaded a script from another site to pin the items to the task bar, but I'm not sure how to get it into the registry after the sysprep. Thanks,
Will

