Occasionally, Windows will create a secondary profile with the naming convention Username.Computername (sometimes it has to do with user temp profiles; other times, workgroup/domain issues that either corrupt the original profile or make it appear corrupted to Windows). Error: User Profile Service failed the logon
Let’s say you don’t want that, how do you fix it? Assuming your regular user profile works, you can just change the user profile path specified in the registry under the ProfileList key. By doing this, you’re telling Windows to not use the newly created profile, and go back to the original one. In theory, you could also just rename the Username.Computer profile to just Username (logged is as Administrator)…and make the ProfileList redirect to C:\Users\Username.
@ECHO OFF
setlocal enableextensions enabledelayedexpansion
set UN=%username%
for /f “delims= ” %%i in (‘”wmic path win32_useraccount where name=’%UN%’ get sid”‘) do (
if not “%%i”==”SID” (
set mySID=%%i
goto :SID_END
)
)
:SID_END
:: SETS THE REG KEY TO SCAN
set REGKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%mySID%
:: CHECKS REG KEY TO SEE IF USER TEMP PROFILE EXISTS – SINGLE PASS
FOR /F “tokens=3” %%j IN (‘C:\Windows\System32\REG.EXE QUERY “%REGKEY%” /v ProfileImagePath’) DO (
IF %%j EQU C:\Users\%UN%.%computername% (
C:\Windows\System32\REG.EXE ADD “%REGKEY%” /v ProfileImagePath /d C:\Users\%UN% /f
)
)
PAUSE
For a better, more usable routine, I will work on adding code to scan for .BAK in the registry – if .BAK exists, delete that whole key.
Update
If you continue to still have problems, ie. a temp profile continues to load, use robocopy to mirror the contents of the username.computername profile (or a simple copy/paste), change the path in the registry under ProfileList to the original profile, and reboot. Note, this has to be done under the Administrator profile.
Reference
https://support.microsoft.com/en-us/kb/947215
http://windows.microsoft.com/en-us/windows/fix-corrupted-user-profile#1TC=windows-7