Cortana/Windows Search breaks in default profile
-
Hi,
i don’t use that tricky registry tweaks for making a profile to default.
Ever tried STRG + SHIFT + F3 in Express Settings to enter Audit mode?
Then do your changes and fire a sysprep:sysprep /oobe /generalize /shutdown /unattend:c:\pathtoanswerfile\unattend.xml
Make sure your unattend.xml has the copyprofile option enabled!!!
Now take your image.If you ever need to make changes restore to vm again let it boot and goto audit mode again: sysprep /audit /reboot
I have that parts scripted for my self and can give you that stuff if you need.
Never try to uninstall staged appx apps or you break sysprep, also don’t use O&O Shutup or Stuff like that this also breaks sysprep.
Regards X23
-
@x23piracy Yes I am aware of the copy profile option and that is a great method for a default profile if you only need one default profile for the image.
The end result of solving this problem was a snapin that deploys a profile to any existing windows 10 computer so that all profiles created after the profile is deployed use the customized default profile. So you can have one base image that can have any number of custom profiles added to it.
It doesn’t require the registry tweaks or anything like that. Just plain and simple copies the files that contain the settings that will create your customized profile when a new profile is created.So you could use this method to have one image with all your programs installed and use profiles to give access to only the programs needed to different departments.
Or you could document what programs have shortcuts in each profile for each department and use fog groups to deploy the programs needed and then the profile provisioning style.
I’m sure there are other methods to do this. For example there are some group policies that can be used. This is just my solution to the problem of customizing local profiles without breaking the profiles and while still allowing users to customize the profiles themselves.
-
@Arrowhead-IT I’ve been trying to use the scripts you posted - lots of things going wrong.
I sorted a permissions issue on the intended share first, but I’m still getting a lot of access denied errors… Suppose I need to dig deeper, run the script as elevated.
My intention is to re-write this thing to be more simple. It’s highly complex I feel, and really overkill.
-
@Wayne-Workman I do have a tendency to do that, complicating things and adding some overkill. You do need to run it as elevated because I think doing anything to the hidden C:\Users\Default folder requires elevation.
The access denied errors are usually solved by copying the script to the C drive to run locally, which is why it copies itself to the C drive to run locally. Windows command prompt and network unc paths don’t always get along. The copySelf function was my solution.
-
@Arrowhead-IT Got this working, Now I understand the beauty of these two scripts design.
-
@Arrowhead-IT said in Cortana/Windows Search breaks in default profile:
some quick notes. You do need to put your username and password in plain text for shares, unless you have shares that give everyone access. If anyone knows of a way to encrypt that, I’d love to hear it. I know it can be done with openssl in linux bash scripts but I am yet to find the equivalent for a batch script. But hey bash will come to windows 10 soon.
This script hasn’t been tested for windows 7 or 8 profiles. It does detect the windows version because I was preparing to add that kind of functionality but since I am ending up moving completely to windows 10, I never put the work into it
The create profile script prompts you for the name of the user profile you customized and asks you for what department/profile you are making it for.
The Apply simply takes one arguement of the profile name. So you can upload just the one script to fog and make a bunch of snapins with different args for each profile you have to deploy.
Also note that I have some extra app data folders for custom settings of specific programs we use. I left them in there as examples.
Bath script to create Deployable Default Profile
::----------------------------------------------------------------------------- :: Script Name: Create-Deployable-Default-Profile :: Original Author: jfullmer :: Created Date: 2016-02-18 16:39:23 :: Last Updated Date: 2016-04-12 17:09:35 :: Update Author: jfullmer :: Version: 3.8 ::----------------------------------------------------------------------------- @ECHO OFF REM @ECHO off to not output the commands being run to the console REM This script copies a Customized windows 10 profile to the default profile so that REM all new profiles are created with the same settings SET pwd=%~dp0 call :main del C:\Create-Deployable-Default-Profile.bat & exit :main REM main Function that just calls the other Functions call :copySelf call :funcHead "Welcome to the Windows Default Profile Creator Script!" call :setVars call :funcHead "Copying Customized Profile From %custom% to %default% ..." call :AppData call :CustomSettings call :CopyToNetwork call :funcHead "Done creating custom default profile! & echo.Goodbye" EXIT /B :copySelf rem In some instances running this from a share doesn't work, so copy itself and start the copied version to run local IF NOT %pwd%==C:\ ( echo. Copying self to C drive net use \\path\to\share /USER:domain\user password XCOPY \\path\to\share\Create-Deployable-Default-Profile.bat C:\ /H /Y rem Make sure it's being run as an admin net session >nul 2>&1 if %errorLevel% == 0 ( echo opening copied version. start C:\Create-Deployable-Default-Profile.bat exit ) else ( echo This needs to be run as admin, try again please. @pause exit ) ) EXIT /B :setVars REM Function to set script variables REM c stands for Custom, d stands for default. cUser should be the name of the user you Customized REM These variables just point to the user folders and the local and roaming appdata folders that REM store all the settings for a user profile call :funcHead "Setting directory variables..." rem set cUser=adl echo. Don't run this script from the user you're copying! set /p cUser="What is the username of the profile you customized? -> " set custom=C:\Users\%cUser% set default=C:\Users\Default set cPF=C:\Users\%cUser%\AppData\ProgramFiles set dPF=C:\Users\Default\AppData\ProgramFiles set cLocal=C:\Users\%cUser%\AppData\Local set dLocal=C:\Users\Default\AppData\Local set cRoam=C:\Users\%cUser%\AppData\Roaming set dRoam=C:\Users\Default\AppData\Roaming rem The script will create windows version and department folders set profiles=\\path\to\share\with\profiles net use %profiles% /USER:domain\user password call :OSversion call :setDept call :dots EXIT /B :setDept rem Function to set department via prompt. echo. What department/group is this profile for? (no spaces) echo. The Current Choices are... (A different entry will create a new folder) rem list profiles dir /b %profiles%\%winVer% set /P dept="Enter The Dept Here -> " set share=%profiles%\%winVer%\%dept% if NOT EXIST %share% mkdir %share% if NOT EXIST %share%\logs mkdir %share%\logs set logs=%share%\logs EXIT /B :OSversion :: Function to get current OS version echo. Getting OS... FOR /F "tokens=4-5 delims=. " %%i in ('ver') do set os=%%i.%%j if "%os%" == "5.1" set winVer=WinXP if "%os%" == "5.2" set winVer=WinXP if "%os%" == "6.1" set winVer=Win7 if "%os%" == "6.2" set winVer=Win8 if "%os%" == "6.3" set winVer=Win8.1 if "%os%" == "10.0" set winVer=Win10 EXIT /B :copyDir REM Function inputs - 1 = display of what is copying 2 = source folder 3 = destination folder REM This Function simply displays what you're copying and copies it. Did a Function to have less REM copy paste of command line options and have cleaner code. REM Note that when calling the Function all passed parameters should be encased in double quotes REM otherwise ROBOCOPY won't read the directories as seperate REM ROBOCOPY or robust copy, is a tool for copying directories or files in windows command line REM The syntax is ROBOCOPY sourceFolder DestFolder options REM the options used make it so a mirrored version of the source and its subdirectories are copied REM to the destination with 64 threads (64 files at once) overwriting existin files retrying any failed files REM only once after 1 second of waiting and all without any verbose output REM /S - subdirectories /MIR - mirror /MT:64 - multithreaded copy with 64 threads, i.e. 64 files at a time instead of 1. REM /LOG - output to logfile instead of console, ROBOCOPY /? says this provides better performance in multithreaded mode REM /IS - include same files i.e. overwrite existing /R:1 retry on error once (default is 1 million) REM W:1 - wait one second between retry on error (default is 30 seconds) REM the /N* are all to decrease output for automation. Since they go to a log file you can take them out if you want ( I did take them out) REM /NP - no progress /NS - don't log file sizes /NC - don't log file classes /NFL - don't log file names /NDL - don't log directory names REM /NJH - no job header /NJS - no job summary echo. Copying %~1... ROBOCOPY "%~2" "%~3" /S /MIR /MT:128 /LOG:"%logs%\%~1.log" /IS /R:1 /W:1 /ZB echo. Done Copying %~1 EXIT /B :AppData REM Function to copy all Customizations settings that are stored in files in the AppData folder call :funcHead "Copying Customizations From AppData..." REM directories used in all versions of windows call :copyDir "Desktop" "%custom%\Desktop" "%default%\Desktop" call :copyDir "Firefox Customizations" "%cRoam%\Mozilla" "%dRoam%\Mozilla" call :copyDir "Google Chrome Customizations" "%cLocal%\Google" "%dLocal%\Google" call :copyDir "Task Bar Pin Shortcuts" "%cRoam%\Microsoft\Internet Explorer" "%dRoam%\Microsoft\Internet Explorer" call :copyDir "Saleslogix" "%cRoam%\Saleslogix" "%dRoam%\Saleslogix" call :copyDir "Sage Software" "%cRoam%\Sage Software" "%dRoam%\Sage Software" call :copyDir "Saleslogix" "%cLocal%\Saleslogix" "%dLocal%\Saleslogix" call :copyDir "Sage Software" "%cLocal%\Sage Software" "%dLocal%\Sage Software" rem IF %dept%==IT ( rem call :copyDir "Terminals" "%cLocal%\Robert_Chartier" "%dLocal%\Robert_Chartier" rem call :copyDir "VMware Vsphere" "%cLocal%\VMware" "%dLocal%\VMware" rem call :copyDir "VMware Vsphere" "%cRoam%\VMware" "%dRoam%\VMware" rem call :copyDir "Camtasia" "%cRoam%\TechSmith" "%dRoam%\TechSmith" rem call :copyDir "Camtasia" "%cLocal%\TechSmith" "%dLocal%\TechSmith" rem call :copyDir "slack" "%cLocal%\slack" "%dLocal%\slack" rem call :copyDir "ProgramFiles" %cPF% %dPF% rem ) call :copyDir "VLC settings" "%cRoam%\vlc" "%dRoam%\vlc" call :copyDir "FaxFinder settings" "%cRoam%\FaxFinder Client Software" "%dRoam%\FaxFinder Client Software" REM The remaining dirs are specific to Windows 10 REM Note: A starup script will be required on first login to copy the favorites for Microsoft edge to the Packages directory in the newly created User REM That logon script would only need to be one line like so... REM ROBOCOPY "%localAppData%\MicrosoftEdge\User" "%localAppData%\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\MicrosoftEdge\User" /S /MIR /MT:64 /LOG:C:\logs\edgeBookmarks.txt /IS /R:1 /W:1 rem call :copyDir "Microsoft Edge Customizations" "%cLocal%\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\MicrosoftEdge\User" "%dLocal%\MicrosoftEdge\User" call :copyDir "Start Menu Tiles Part 1 of 3" "%cLocal%\TileDataLayer" "%dLocal%\TileDataLayer" call :copyDir "Start Menu Tiles Part 2 of 3" "%cRoam%\Microsoft\Windows\Start Menu" "%dRoam%\Microsoft\Windows\Start Menu" call :copyDir "Start Menu Tiles Part 3 of 3" "%cLocal%\Microsoft\Windows\Shell" "%dLocal%\Microsoft\Windows\Shell" echo. Done Copying AppData Folders... call :dots EXIT /B :CustomSettings REM This Function copies the ntuser.dat and related system files that store things like task bar pin order, REM mapped network drives, taskbar toolbars, explorer settings, desktop background settings, etc. REM It uses xcopy to copy all files that start with ntuser via * wildcard and uses the options... REM \H - copy hidden system files /Y - overwrite existsing files without prompt call :funcHead "Copying custom settings (i.e. task bar pins and toolbars, desktop background, etc.) from ntuser .dat system files..." XCOPY %custom%\ntuser* %default%\ /H /Y > %logs%\ntuserFiles.log echo. Done Copying Custom Settings call :dots EXIT /B :CopyToNetwork REM This copies the newly created profile to the network share call :funcHead "Copying profile to network!" ROBOCOPY %default% %share%\Default /S /MIR /R:1 /W:1 /MT:128 /ZB /XJ XCOPY %default%\ntuser* %share%\Default\ /H /Y > %logs%\ntuserFilesRemote.log net use %share% /delete EXIT /B :dots REM just echoing dots in a Function instead of copy pasting them so that it's consistent echo ...................................................................... EXIT /B :funcHead REM A simple function for displaying a consistent header at the start of functions call :dots echo. %~1 call :dots EXIT /B
Batch script/snapin to Apply Default Profile
::----------------------------------------------------------------------------- :: Script Name: Apply-Default-Profile-args :: Original Author: jfullmer :: Created Date: 2016-02-18 16:39:27 :: Last Updated Date: 2016-05-11 16:29:08 :: Update Author: jfullmer :: Version: 2.7 ::----------------------------------------------------------------------------- @ECHO OFF REM @ECHO off to not output the commands being run to the console REM Requires args passed of department rem if department is Touchscreen autologon is enabled and fog will reboot after applying the profile set dept=%1 call :OSversion call :main exit :main REM main Function that just calls the other Functions call :funcHead "Welcome to the Windows 10 Default Profile Copy Script!" call :setVars call :CopyFromNetwork call :funcHead "Done creating custom default profile! & echo.Goodbye" EXIT /B :setVars REM Function to set script variables REM c stands for Custom, d stands for default. cUser should be the name of the user you Customized REM These variables just point to the user folders and the local and roaming appdata folders that REM store all the settings for a user profile call :funcHead "Setting directory variables..." set cUser=adl set custom=C:\Users\%cUser% set default=C:\Users\Default set cLocal=C:\Users\%cUser%\AppData\Local set dLocal=C:\Users\Default\AppData\Local set cRoam=C:\Users\%cUser%\AppData\Roaming set dRoam=C:\Users\Default\AppData\Roaming set share=\\path\to\share\%winVer%\%dept% net use %share% /USER:domain\user password call :dots EXIT /B :OSversion :: Function to get current OS version echo. Getting OS... FOR /F "tokens=4-5 delims=. " %%i in ('ver') do set os=%%i.%%j if "%os%" == "5.1" set winVer=WinXP if "%os%" == "5.2" set winVer=WinXP if "%os%" == "6.1" set winVer=Win7 if "%os%" == "6.2" set winVer=Win8 if "%os%" == "6.3" set winVer=Win8.1 if "%os%" == "10.0" set winVer=Win10 EXIT /B :CopyFromNetwork REM This copies the newly created profile to the network share call :funcHead "Copying profile From network!" echo. Delete and recreate default profile folder so there aren't remnants of other profiles... rmdir %default% /S /Q mkdir %default% ROBOCOPY %share%\Default %default% /S /MIR /R:1 /W:1 /MT:128 /ZB /LOG:C:\defaultProfileApplied-%dept%.log XCOPY %share%\Default\ntuser* %default%\ /H /Y > C:\defaultProfile-ntuser-%dept%.log net use %share% /delete EXIT /B :dots REM just echoing dots in a Function instead of copy pasting them so that it's consistent echo ...................................................................... EXIT /B :funcHead REM A simple function for displaying a consistent header at the start of functions call :dots echo. %~1 call :dots EXIT /B
Imma say #wiki -worth?
-
@Wayne-Workman What if anything did you have to change?
-
@Arrowhead-IT I removed the copy self line so that doesn’t run, as I’m just running the script from the c:\ drive.
I want all users to use the same profile defaults, so I don’t need more than one.
I named the group “default” when prompted, and then in the deployment script I just hard coded “default” where it normally grabs the group arguments.
-
@Arrowhead-IT So - I can copy the profile I’ve set up to a share, and can use a snapin to copy it back down.
it appears to copy correctly, because I can see the size change in c:\Users\default
However, start menu tile settings are clearly not applying - also I’m still getting the nasty “We’re glad you’re here” stuff upon a user’s first login.
-
Ok, update.
For whatever reason, the profile didn’t apply for one account, but trying another and it DID apply!
Weird…
-
@Wayne-Workman Hmmm, I haven’t had that login screen popup, there are some group policies in Computer Config → Admin Templates → System → Logon to implicitly stop the sign-in animation/getting started welcome screen. I don’t have them configured.
Did the profile that didn’t get created perhaps already have a user folder? i.e the user name was Wayne and it was used to create the profile in the image and its folder still existed in C:\users\Wayne? If the folder already exists it can cause issues. My local files restore script gets around that by waiting for the user profile to be created. The user folder already existing and the computer having just gone through sysprep is the only way I can think of that would make it not work right. And even then, it would usually just create a new one with a user folder named name.domain or something of that sort.
Every once in a while I do see some start menu tiles issues. It’s intermittent and I haven’t narrowed it down. All the tiles will be there but the icons are missing. If you resize any tile the icon comes back. I usually just recreate the profile via the script if I find that is happening with a specific profile and it fixes the issue for future deployment. One tile that loves to give trouble randomly is chrome. Stupid chrome. The resize trick doesn’t always work on it and it has to be unpinned and repinned. It doesn’t always happen though, I think it has something to do with chrome’s auto updating to new versions or something.
So it isn’t a 100% flawless system. But resizing a couple start screen icons is a lot less time then customizing an entire profile every time. And probably 99% of the time it just plain works for me. Just the occasional start menu pin icon disappears.
-
@Arrowhead-IT said in Cortana/Windows Search breaks in default profile:
Did the profile that didn’t get created perhaps already have a user folder?
Totally possible.
there are some group policies in Computer Config → Admin Templates → System → Logon to implicitly stop the sign-in animation/getting started welcome screen.
I’ll look into that.
So it isn’t a 100% flawless system.
Still planning on doing a re-write… I’m just still wrapping my head around Win10 profiles and trying different things still.
-
This is a great post and the script is awesome! However, after multiple tests I’m finding that it does continue to break Cortana and the Start Menu on my image which is Win 10 Enterprise. It does seem to work as intended otherwise, as wallpaper, pinned taskbar programs and Firefox settings all seem to be in place.
-
@csuther3 that’s strange. I tested on win10 enterprise and the start menu and search remains fine.
Something that might help you: I noticed the files copied totaled about 40 ish MB.
-
@csuther3 Are you copying from a profile that already has cortana broken? Because it doesn’t fix it in that manner. You have to start with a fresh standard windows profile, then customize it.
-
@Arrowhead-IT No, Cortana and the Start Menu are both working fine in the source account, but once copied to the default profile Cortana and the Start Menu do not work for any new accounts. I tried creating the profile from a local user account as well as from a domain user account and it did not make a difference. I have my image in a VM so I can use a snapshot to quickly “unbreak” the default profile if you have any thoughts on things to try.
-
To my knowledge, you can’t just copy profiles from one account to another as it causes issue.
I think the better path to walk is to manipulate the registry entries for the default user profile and save those keys in a reg file to be applied at any time (or alternatively simply collect the registry manipulation in a batch file, same result really).
I use a combination of registry manipualtion and regular file adding/removing to customize the default user. It’s not perfect, but it doesn’t cause issues and has saved us a lot of time.
This part copies the theme from our local NAS and then manipulates the registry entries for default users so it becomes the default theme for any new user.
copy /y "\\path\to\theme\theme.themepack" %SYSTEMROOT%\Resources\Themes\ cmd /c reg load HKU\TempHive "%SystemDrive%\Users\Default\NTUSER.DAT" cmd /c reg add HKU\TempHive\Software\Microsoft\Windows\CurrentVersion\Themes /v CurrentTheme /t REG_SZ /d "%SYSTEMROOT%\Resources\Themes\theme.themepack" /f cmd /c reg unload HKU\TempHive
-
@csuther3 That is odd, I haven’t had that issue, and I’ve made profiles with this with local and domain accounts successfully, I think doing it from a local account is a better practice though. I also make them from a VM.
Maybe there’s an indication in the log files. There shouldn’t be any sensitive information in the log so post away.
When you create a profile the logs go in a logs folder in that profiles share folder. i.e \profilesShare\Win10\ProfileName\logs
Then when the profile is applied a log is created on the root of the C drive on the computer it was applied on. -
@Quazz That is an intriguing method. Your editing the default NTUSER.dat file instead of just copying over a newly created one. Do you know what the theme contains? I was under the impression that the theme is just the desktop background and things of that nature. I know that the taskbar pins are a mix of something in the ntuser.dat hive and the shortcut icons in AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar. But I don’t know the exact part of the hive that sets that off the top of my head. Does your method customize the taskbar pins and toolbars? The start screen pins are also in a few database files that I have no idea how to edit manually (I have tried only a little), and I think that there are some linked registry hive entries for that too. I think there are still some files that need to be copied for full customization, but I kinda love the idea of editing the original ntuser.dat, but I didn’t think it was as simple as a few commands. I’ve loaded the hive in regedit before, but manual edits in that manner are risky and I ran into some things that were completely in binary.
Another thing I customize is a old fashioned startmenu. I figured this out with windows 8. Right click the taskbar and go to toolbars→new toolbar and point it to “%APPDATA%\Microsoft\Windows\Start Menu\Programs” This will point it to the current user’s start menu. I then customize that folder down to just a few organized folders with the installed programs. (I hide instead of deleting the default windows system shortcuts though, because otherwise sfc /scannow thinks they’re missing and restores them.) I also unlock the taskbar and move it over to the left (sometimes have to drag taskbar buttons to the right of it) then re-lock the taskbar and violia old fashioned start menu programs menu. None of this forcing alphabetic order without any subfolders and a bunch of windows apps you don’t care about (not that all windows apps are useless, they just aren’t really needed in a business environment). Granted, I believe that I did find a registry entry linked to that toolbar and it’s path and location on the taskbar. I tried to create it into a machine instead of user hive to no avail. But perhaps I might be able to utilize this method for the ntuser.dat.
TL;DR
Cool script, I’m going to take that idea and see if it improves the stability of my script for the ntuser.dat aspect. -
@Arrowhead-IT The theme sets system sounds and background such only, yes.
For taskbar pins, I simply copy over pre-created shortcut links to the appropriate folder.
Removing the default ones is trickier because there doesn’t seem to be a built-in way of accomplishing it.
I’m still working on a lot of this stuff, but I believe currently I simply remove them during setupcomplete from both the default and currently created user. I haven’t been able to test this out yet however.
“%SystemDrive%\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Windows Media Player.lnk” should be the path to the windows media player link for example.