Update: August 8, 2015 - Microsoft have discontinued the Microsoft Download Manager as of March 2015, so the below workload will no longer work. If fact there are no workaround now, you’ll need to rely on your browser’s download manager. See this article for more info: Using Subscriber Downloads
The Deployment Guys have a great article from 2009 that I recommend reading for a overview of customisation methods: Configuring Default User Settings – Full Update for Windows 7 and Windows Server 2008 R2. This article is still applicable today and the process hasn’t changed that much between Windows versions. Here are most of the ways that you could edit the default user profile:
Copy a configured profile over the default profile - this is the most common way of changing the default user experience but this approach is unsupported by Microsoft and therefore I recommend against using it.
Using Sysprep and the CopyProfile value - this approach requires creating a reference image and using Sysprep to generalise the image. Many enterprise desktop deployments will use reference images so this isn’t too hard; however Microsoft has not documented every setting that is copied to the default user profile, so it’s a bit of pot luck.
Place a default profile in NETLOGON - a default profile copied to the NETLOGON share of a domain controller (and replicated) will be copied down to the local machine at first logon. The downside of this approach is that there can be only one default profile and it will be copied to all machines, regardless as to whether the profile should apply to that machine or not.
Commands or scripts run from the RunOnce Registry key to edit the user profile.
Logon scripts to edit the user profile.
Group Policy Preferences - GPP has become more prevalent in the past few years, so should now be available across the board.
Editing the default profile directly, typically during an automated deployment, but you could run the same script on any existing PC.
So there are multiple methods (of driving yourself to madness), I’d recommend experimenting with each approach and you’ll most likely implement a combination of approaches to best suit your environment.
Group Policy As A Last Resort
Group Policy is great, until it isn’t. Group Policy is pervasive and every Windows admin is familiar with it, but there a two things to consider when using it to manage the default user experience:
Group Policy is is a policy - that is, if you’re using policies to manage default user settings, the user cannot then change to their own preference.
Group Policy Preferences must be processed to determine whether they have been applied. Whilst GPPs can implement a preference rather than a policy, Windows must determine whether the preference has been applied by reading a flag. Whilst checking those flags isn’t a big problem, implementing GPPs should be considered in the context of whatever else is running at logon, how many preferences are implemented plus what happens to the environment over time (how many additional policies, applications, scripts etc. will be added to the environment over the life of that desktop).
I have seen many organisations over-relying on Group Policy and missing the most important component user environment management - change control and ownership. Group Policy becomes a black hole, complete with settings that no one can remember why they were implemented and settings that are no longer relevant. Group Policy Preferences are great for replacing logon scripts, but use Group Policy and GPP sparingly so as not to adversely affect the user experience.
A Better Way - Edit the Default Profile Directly
My preferred method for modifying the default user experience is to edit the default user profile directly using a script that is run during Windows deployment. This type of script can also be run on existing machines or used in combination with CopyProfile. A benefit of this approach is that you can modify the default profile with or without a reference image.
Editing the Default Profile
To edit the default profile, we’ll use the command line tool REG to mount and make changes to the default user registry hive. Additionally we can make folder and file changes to the default profile and a couple of other command line tools to perform tasks such as pin and unpin shortcuts or change the Windows 7 Libraries. As far as this article is concerned, the default profile is in its default location, usually C:\Users\Default. In a script, you could refer to this location as %SystemDrive%\Users\Default.
Finding Settings
To find the profile locations to modify there’s a couple of methods that I rely on:
Google (or your favourite search engine)
Process Monitor and Process Explorer
In most cases, someone (or even Microsoft) will have documented a registry value or profile location that is used to store a setting. More obscure or new settings will require detecting the location with Process Monitor. For example, to determine where a setting is stored in the Registry, create a filter in Process Monitor using the process name or process ID, additionally filtering on the operation such as RegSetValue, as shown below:
A trace with Process Monitor when making a preference change should result in something like this:
Regshot is also useful for comparing a before and after change to the profile for determining registry value locations.
Additionally Process Explorer can be useful for tracking down a process that might be responsible for writing a setting by viewing the command line used to launch the process. Finding settings can sometimes be a time consuming process, but once found and documented, you’ve got a detailed understanding of the default profile.
Editing the Registry
To make direct registry edits to the default user profile, the REG command line utility is used to load the default profile registry hive, change a registry value and then unload the hive, saving it back to the default profile. The following lines show a rough example of how this is done:
Note that this will need to be run with administrative privileges and in an elevated context, so that you have write access to the default profile.
Pinning and Unpinning Shortcuts
A common requirement is to modify the the pinned shortcuts on the Taskbar or Start menu. This can be automated using a script, which needs to run a first logon (either as the user, or in the profile copied over the default profile via Sysprep/CopyProfile). Unfortunately I can’t find the original source for this script; however it works quite well and allows you to pin shortcuts to and unpin shortcuts from the Taskbar and Start menu via a command line. The script is available here:
' USAGE: cscript.exe ExecuteVerbAction.vbs <file path> <verb name>' Example: Pin the outlook shortcut to the start menu' cscript.exe ExecuteVerbAction.vbs "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office Outlook 2007.lnk" PinToStartMenu' Example: Unpin the outlook shortcut from the start menu' cscript.exe ExecuteVerbAction.vbs "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Media Player.lnk" UnpinFromStartMenu'' COMMENT: This script executes defined file-verb' CHANGELOG: 2010-04-06 - Script Created'' Supported VerbActions:' PinToStartMenu (Pin to Start Menu)' UnpinFromStartMenu (Unpin from Start Menu)' PinToTaskbar (Pin to Taskbar)' UnpinFromTaskbar (Unpin from Taskbar)' PinLocations:' Start Menu, Taskbar'-------------------------------------------------------------------------------------------------------------------DimdefinedVerbActions,folderItem,filePath,verbAction,returnCode,procOwnerConstDebugEnabled=falseDimScriptName:ScriptName=WScript.ScriptNameIf(GetProcessOwner(procOwner))ThenDebugInfo("procOwner = "&procOwner)IfNot(ValidateArguments())ThenDebugInfo("ValidateArguments(), return = false")WScript.Quit(1)EndIffilePath=WScript.Arguments.Item(0)verbAction=WScript.Arguments.Item(1)DebugInfo("filePath = "&filePath)DebugInfo("verbAction = "&verbAction)'DisplayFolderItemVerbs(filePath)SetdefinedVerbActions=GetDefinedVerbActions()SetfolderItem=GetFolderItem(filePath)If(folderItemIsNothing)ThenDebugInfo("GetFolderItem("&filePath&"), return = null")WScript.Quit(0)EndIfreturnCode=trueSelectCaseverbActionCase"PinToStartMenu"IfNotIsPinned(filePath,"Start Menu")ThenreturnCode=ExecuteFolderItemVerbAction(folderItem,definedVerbActions.Item(verbAction))EndIfCase"UnpinFromStartMenu"IfIsPinned(filePath,"Start Menu")ThenreturnCode=ExecuteFolderItemVerbAction(folderItem,definedVerbActions.Item(verbAction))EndIfCase"PinToTaskbar"IfNotIsPinned(filePath,"Taskbar")ThenreturnCode=ExecuteFolderItemVerbAction(folderItem,definedVerbActions.Item(verbAction))EndIfCase"UnpinFromTaskbar"IfIsPinned(filePath,"Taskbar")ThenreturnCode=ExecuteFolderItemVerbAction(folderItem,definedVerbActions.Item(verbAction))EndIfEndSelectIfNotreturnCodeThenDebugInfo("ExecuteFolderItemVerbAction() return = "&returnCode)WScript.Quit(1)EndIfDebugInfo("ExecuteFolderItemVerbAction() return = "&returnCode)WScript.Quit(0)FunctionValidateArguments()DimvalidArguments,filePath,verbAction,oFsoDimdefinedVerbActions,validShortCut,validVerbActionvalidArguments=falsevalidShortCut=falsevalidVerbAction=falseSetoFso=CreateObject("Scripting.FileSystemObject")SetdefinedVerbActions=GetDefinedVerbActions()DebugInfo("ValidateArguments::WScript.Arguments.Count = "&WScript.Arguments.Count)If(WScript.Arguments.Count=2)ThenfilePath=WScript.Arguments.Item(0)verbAction=WScript.Arguments.Item(1)If(oFso.FileExists(filePath)AndFileIsShortcut(filePath))ThenvalidShortCut=trueIfdefinedVerbActions.Exists(verbAction)ThenvalidVerbAction=trueIf(validShortCutAndvalidVerbAction)ThenvalidArguments=trueIf(NotoFso.FileExists(filePath))ThenDebugInfo("ValidateArguments::FilePath = false")If(NotoFso.FileExists(filePath))ThenvalidArguments=trueEndIfDebugInfo("ValidateArguments::validShortCut = "&validShortCut)DebugInfo("ValidateArguments::validVerbAction = "&validVerbAction)ValidateArguments=validArgumentsSetdefinedVerbActions=NothingSetoFso=NothingEndFunctionFunctionGetFolderItem(ByValfilePath)OnErrorResumeNextDimoFso,shell,folder,folderItemDimfolderPath,fileNameSetoFso=CreateObject("Scripting.FileSystemObject")Setshell=CreateObject("Shell.Application")SetfolderItem=NothingIf(oFso.FileExists(filePath))ThenfolderPath=Mid(filePath,1,InStrRev(filePath,"\")-1)fileName=Mid(filePath,InStrRev(filePath,"\")+1)Setfolder=shell.Namespace(folderPath)IfNot(folderIsNothing)ThenSetfolderItem=folder.ParseName(fileName)EndIfSetGetFolderItem=folderItemSetshell=NothingSetoFso=NothingEndFunctionFunctionIsPinned(ByValfilePath,ByValpinLocation)DimfolderItem,itemIsPinned'DebugInfo("IsPinned(" & filePath & ", " & pinLocation & ")")itemIsPinned=falseSetfolderItem=GetFolderItem(filePath)IfVerbActionExists(folderItem,"Unpin from "&pinLocation)ThenitemIsPinned=trueDebugInfo("IsPinned::itemIsPinned = "&itemIsPinned)IsPinned=itemIsPinnedSetfolderItem=NothingEndFunctionFunctionVerbActionExists(ByReffolderItem,ByValverbAction)DimactionExists,verbVerbActionExists=FalseIf(folderItemIsNothing)ThenExitFunctionForeachverbinfolderItem.Verbs()If(UCase(verbAction)=UCase(GetVerbAction(verb)))ThenVerbActionExists=TrueExitForEndIfNextEndFunctionFunctionExecuteFolderItemVerbAction(ByReffolderItem,ByValverbAction)OnErrorResumeNextDimverbExecuteFolderItemVerbAction=FalseIf(folderItemIsNothing)ThenExitFunctionIfVerbActionExists(folderItem,verbAction)ThenSetverb=GetVerbForVerbAction(folderItem,verbAction)verb.DoIt()IfErr=0ThenExecuteFolderItemVerbAction=TrueDebugInfo("ExecuteFolderItemVerbAction::verb.DoIt(), return = "&Err)Err.ClearSetverb=NothingEndIfEndFunctionFunctionGetVerbForVerbAction(ByReffolderItem,ByValverbAction)DimreturnVerb,verbSetreturnVerb=NothingForeachverbinfolderItem.Verbs()If(UCase(verbAction)=UCase(GetVerbAction(verb)))ThenSetreturnVerb=verbExitForEndIfNextSetGetVerbForVerbAction=returnVerbEndFunctionFunctionGetVerbAction(ByValverb)DimverbActionverbAction=verb.NameIfInStr(verb.Name,"&")ThenverbAction=replace(verb.Name,"&","")GetVerbAction=verbActionEndFunctionFunctionGetDefinedVerbActions()DimverbActionsConstCompareMode_CaseInsensitive=1'// Text compare modeSetverbActions=CreateObject("Scripting.Dictionary")verbActions.CompareMode=CompareMode_CaseInsensitiveverbActions.Add"PinToStartMenu","Pin to Start Menu"verbActions.Add"UnpinFromStartMenu","Unpin from Start Menu"verbActions.Add"PinToTaskbar","Pin to Taskbar"verbActions.Add"UnpinFromTaskbar","Unpin from Taskbar"SetGetDefinedVerbActions=verbActionsEndFunctionFunctionFileIsShortcut(ByValfilePath)DimfolderItemFileIsShortcut=falseSetfolderItem=GetFolderItem(filePath)IfNot(folderItemIsNothing)ThenFileIsShortcut=folderItem.IsLinkSetfolderItem=NothingEndFunctionSubDisplayFolderItemVerbs(ByValfilePath)DimfolderItem,iSetfolderItem=GetFolderItem(filePath)'WScript.Echo "folderItemVerbs: " & folderItem.Verbs.CountFori=0TofolderItem.Verbs.Count-1'WScript.Echo i & " = " & folderItem.Verbs.Item(i)NextEndSubFunctionDebugInfo(ByValinfo)ConstLogTypeSuccess=0ConstLogTypeInformation=4info=ScriptName&" -> "&infoWScript.EchoinfoIfDebugEnabledThenDebugInfo=LogMessage(LogTypeInformation,info)EndFunctionFunctionLogMessage(ByVallogType,ByValmsg)DimoWshShellSetoWshShell=CreateObject("WScript.Shell")LogMessage=oWshShell.LogEvent(logType,msg)SetoWshShell=NothingEndFunctionFunctionGetProcessOwner(ByRefprocOwner)OnErrorResumeNextDimwmiQuery,oWMIService,processes,processDimprocessName,username,domainGetProcessOwner=falseprocessName=Mid(WScript.FullName,InStrRev(WScript.FullName,"\")+1)SetoWMIService=GetObject("winmgmts:"_&"{impersonationLevel=impersonate}!\\.\root\cimv2")wmiQuery="SELECT * FROM Win32_Process WHERE Name = '"&processName&"'"Setprocesses=oWMIService.ExecQuery(wmiQuery)ForEachprocessinprocessesIf(InStr(process.CommandLine,WScript.ScriptName)<>0)ThenIf(process.GetOwner(username,domain)=0)ThenprocOwner=domain&"\"&usernameGetProcessOwner=trueEndIfExitForEndIfNextOnErrorGoTo0Setprocesses=NothingSetoWMIService=NothingEndFunction
By default, the Libraries introduced in Windows 7, include the public folder locations. Removing these or adding locations requires editing the Libraries; however they’re stored in XML files and are created at first logon. To modify the libraries, you can use a command line tool ShLib.exe. Like pinning and unpinning shortcuts, this tool also needs to be run at first logon (and won’t work via CopyProfile). This article, Administratively Create and Modify Windows 7 Libraries, covers the use of ShLib.exe quite well.
Implementing a Script to Modify the Default Profile
Once you’ve created your script to make changes to the default registry, modify the default profile folder locations, pin and unpin shortcuts and make changes to the Libraries, you’ll need to implement the changes on the target PCs via script. Using an automation solution such as the Microsoft Deployment Toolkit (or an ESD like System Center Configuration Manager) the script can be run during a deployment task sequence. In the case of MDT, the script will be run after Windows unattended setup has completed in the local Administrator context. This way the script will have full elevation and write access to the default profile. An ESD solution will typically run the script via the local SYSTEM account. If you need to make changes to existing PCs, you’ll need a method to do so, such as an advertisement in Configuration Manager. If you take this approach, you can combine a script that makes direct changes to the default profile with the CopyProfile approach. That allows you to modify the profile for deployments from an unmodified OS as well as a custom image, keeping consistency across deployment types.
Example Scripts
Included here, along with some notation, are some example scripts for modifying the Windows 7 and Windows 8.1 default profiles. These example scripts include creation of a script at runtime that will run during first logon of any new profile. This is implemented as a batch file to keep things as simple as possible. Users will see a Command Prompt window as the script runs (but only once). The command lines includes in the script could be implemented with a UEM solution such as AppSense Environment Manager or even Group Policy to improve the user experience.
Windows 7
Here’s a sample script that will modify the default profile on a Windows 7 PC (x86 and x64). At a high level, the script will perform the following steps:
Load and modifies the registry of the default profile
Copies ExecuteVerbAction.VBS and ShLib.exe to folder under %ProgramFiles%
Creates a batch script that will run on first logon to edit the Libraries and pin/unpin shortcuts. Once the script runs for the user, it will delete itself.
If you use this in a production environment, please test and confirm each setting to ensure you understand what the script will implement.
Windows 8.1
Here’s a sample script that will modify the default profile on a Windows 8.1 PC (x86 and x64). At a high level, the script will perform the following steps:
Load and modifies the registry of the default profile
Import a pre-configured Start screen
Copies ExecuteVerbAction.VBS and ShLib.exe to folder under %ProgramFiles%
Creates a batch script that will run on first logon to edit the Libraries and pin/unpin shortcuts. Once the script runs for the user, it will delete itself
If you use this in a production environment, please test and confirm each setting to ensure you understand what the script will implement.
Summing Up
There are numerous ways to edit the default profile, some more complicated and involved than others. It’s my view that the best way to modify the default profile is targeting the required settings, which does mean more work. However, this approach results in a better understanding of the user environment and with any luck a better user experience.
Each new major release of Windows results in less modifications, so your job will be easier. There are a few scripts and tools you’ll need to have in place and I’m confident the approach outlined here will result in happy users (or at least users who aren’t complaining).
In the next article on the same subject, I’ll cover customising the default profile for Remote Desktop Services Session Hosts.
I have too many devices but not one of them runs Android. A good part of my job is testing, presenting and demoing, so it’s handy being able to show the user experiences across different devices. One of everything is perhaps going a bit too far, so I’d prefer to run Android as a VM.
Microsoft announced some interesting new features in Windows Server 2012 R2 at TechEd 2013 and one of those that piqued my interest is Work Folders. I’m not the biggest fan of Redirected Folders and Offline files, but it’s essentially the only enterprise solution Microsoft provides today for taking your data offline. Microsoft needs to provide a completely new method of syncing file data - one that is designed for todays use cases and computing environment.
Citrix provides a nice wizard for installing the XenDesktop 7 VDA and some pretty good documentation on using a command line installation, but the wizard does not expose all of the available options and working out what the wizard is doing in relation to the command line takes a bit of translation. Here’s how to automate a typical VDA deployment.
The Microsoft Deployment Toolkit provides a Lite Touch deployment model - typically a device requires an engineer to manually start the deployment task sequence. Using PowerShell to drive MDT offers the chance to provide a little more automation around OS deployments.
in Community on Ilio, Mdt, Powershell, Vsphere, Xendesktop
Here’s a deployment demo that I showed during my Geek Speak Live session at Citrix Synergy 2013 at Anaheim last week as well as during BriForum London 2013 when I had the opportunity to co-present a session with fellow CTP, Jim Moyle.