A Windows repair loop, a healthy drive, and one corrupt registry file
My first LambTech PC customer job. A 2017 all-in-one stuck in Automatic Repair. The drive was fine; one registry hive wasn't. How I saved everything first, found the cause, and put every file back where it lived.
The problem
A customer brought in a 2017 Lenovo all-in-one stuck in Windows 10's "Preparing Automatic Repair" loop. It had years of work files on it, and no recent backup that anyone knew of.
The usual guess for a machine that age is a dying hard drive. It had a 1 TB, 5400 rpm laptop drive and no SSD. But the rule on a customer machine is data first, diagnosis second: nothing writes to that drive until the files are safe.
Step 1: look without touching
- BIOS: photographed every page. UEFI only, firmware TPM on (so BitLocker was possible), Secure Boot on, and the BIOS saw exactly one drive.
- Rescue USB: a Ventoy stick with Hiren's BootCD PE, SystemRescue and MemTest86+, every ISO checked against its published SHA-256. Secure Boot blocked Ventoy, so I disabled it for the job instead of enrolling Ventoy's key on someone else's PC, and noted to turn it back on.
- Drive health: CrystalDiskInfo said "Good", but I read the raw values that matter: reallocated (05), pending (C5), uncorrectable (C6), CRC (C7). All zero, and only ~2,100 power-on hours. The drive was healthy.
- Clues on the C: drive: a
defaultuser1profile dated a few days before the failure, plus$SysResetand$Windows.~BTfolders. A Windows update or "Reset this PC" had started and not finished.
Step 2: back everything up, twice, and verify
I wired the customer PC straight to my workstation with an Ethernet cable on its own isolated port: link-local addressing, no gateway, one shared folder, a dedicated login, and firewall rules scoped to that port. A possibly-infected customer machine can reach that one folder and nothing else on my network.
- Files: robocopy of all of
C:\Users. 50,175 files, and the copy matched the source to the byte. The only "failures" were 24 zero-byteWindowsAppsapp aliases, which aren't real files. - Second copy: on the workstation, SHA-256 verified file by file.
- Extras: Recycle Bin contents, ProgramData, and a list of installed programs.
- Full disk image: my first try was DISM
/Capture-Imagestraight to the network share. It failed twice with error 80 ("file exists") at different points, on different random files, along with flush errors on the WIM. The problem was DISM writing a large WIM over SMB, not the source files. Booting SystemRescue and streamingpartclone.ntfs | zstdto the share worked first try: 64.6 GB of used space in 9½ minutes, plus the small partitions and the GPT table, all checksummed.
Step 3: find the actual cause
An offline repair pass from the PE environment (revert pending update actions, chkdsk /f, offline SFC, DISM ScanHealth, bcdboot) gave the answer in two lines:
Error: 1009. The configuration registry database is corrupt.
A small script tried reg load on each hive. SYSTEM, SOFTWARE, SAM, DEFAULT, COMPONENTS, DRIVERS and the user's NTUSER.DAT all loaded. SECURITY did not. Windows 10's RegBack folder was empty (it's been off by default since 2018), and there were no usable restore points.
I tried replacing SECURITY with a clean stock hive (corrupt one kept, renamed). Windows got further than before, then blue-screened with 0xC00002E3: the Security Account Manager couldn't start, because a stock SECURITY hive doesn't match that machine's SAM. With no matching copy anywhere, in-place repair was a dead end, so I recommended a fresh install, and the customer approved it.
Step 4: reinstall, then restore it like nothing happened
A clean Windows 10 install activated on its own from the key in the firmware. The harder part was making it feel like their computer again.
I read the old user settings offline. reg load refused the copied NTUSER.DAT, so I parsed it with Python (python-registry) instead. Three keys told me everything:
IdentityCRL\UserExtendedProperties: which Microsoft account they used.Explorer\User Shell Folders: Desktop, Documents and Pictures had all been redirected into OneDrive.OneDrive\Accounts\Personal\LastSignInResult = 0x8004DE25: OneDrive's sign-in had been failing. It had silently stopped uploading, which is why the cloud copy was nearly empty. The local drive held the only full copy of their documents.
So the restore put every file back in its original path (merging, never overwriting anything newer), turned OneDrive folder backup back on so it all uploaded, and rebuilt 60 deleted-but-not-emptied files from the Recycle Bin's $I/$R pairs under their real names. Office came back by signing in: the account already owned the license.
Two last gotchas: OneDrive pointed Documents at a brand-new empty Documentos folder (fixed with Location → Move), and the Office installer can't download over the isolated bench cable (it needs real internet, obviously).
Handback
A cleanup script removed my Wi-Fi profile, logs, Explorer history and Start-menu clutter, then reported activation, Secure Boot, device status, folder locations and Office licensing in one pass. Secure Boot went back on. The customer got a two-page report with clickable next steps on their desktop (Settings pages, OneDrive, account security), and my copies of their data are set to be deleted two weeks after pickup.
Lessons
- "Good" in CrystalDiskInfo isn't a diagnosis. Read the raw values.
- Don't stream a big DISM capture over SMB. partclone to a mounted share was faster and just worked.
- A corrupt SECURITY or SAM hive can't be swapped for a stock one. No matching backup means reinstall.
- Check whether OneDrive is actually syncing, not just installed. The registry knows.
- Restore to the original paths. The best repair is the one the customer can't see.
Every script from this job is now a reusable template for the next one.