syntax53

Script to fix broken default profile after windows feature update/upgrade

Nov 21st, 2021 (edited)
1,001
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.34 KB | None | 0 0
  1. SET WINVER=0
  2. for /f "tokens=3" %%A IN ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "DisplayVersion" /reg:64') DO (
  3.     IF NOT "%%A"=="" SET "WINVER=%%A"
  4. )
  5. IF "%WINVER%"=="0" (
  6.     for /f "tokens=3" %%A IN ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ReleaseID" /reg:64') DO (
  7.         IF NOT "%%A"=="" SET "WINVER=%%A"
  8.     )
  9. )
  10.  
  11. IF EXIST "c:\Windows.old\Users\Default\AppData\Local\Microsoft\Windows\usrClass.dat" (
  12.     IF EXIST "c:\Windows.old\Users\Default\NTUSER.dat" (
  13.         IF NOT EXIST "c:\Users\Default\AppData\Local\Microsoft\Windows\usrClass.dat" (
  14.             IF NOT EXIST "c:\windows\temp\NTUSER_%WINVER%.dat.bak" copy /y "c:\users\default\ntuser.dat" "c:\windows\temp\NTUSER_%WINVER%.dat.bak"
  15.             IF EXIST "c:\windows\temp\NTUSER_%WINVER%.dat.bak" (
  16.                
  17.                 attrib -h "c:\Windows.old\Users\Default\AppData\Local\Microsoft\Windows\usrClass.dat"
  18.                 copy "c:\Windows.old\Users\Default\AppData\Local\Microsoft\Windows\usrClass.dat" "c:\Users\Default\AppData\Local\Microsoft\Windows\usrClass.dat"
  19.                
  20.                 attrib +h "c:\Windows.old\Users\Default\AppData\Local\Microsoft\Windows\usrClass.dat"
  21.                 attrib +h "c:\Users\Default\AppData\Local\Microsoft\Windows\usrClass.dat"
  22.                
  23.                 attrib -h "c:\Windows.old\Users\Default\NTUSER.dat"
  24.                 copy /y "c:\Windows.old\Users\Default\NTUSER.dat" "c:\users\default\ntuser.dat"
  25.             )
  26.         )
  27.     )
  28. )
  29.  
Add Comment
Please, Sign In to add comment