How To Fix Unexpected Computer Restart or Error

Yeah, if you’ve ever seen “The computer restarted unexpectedly or encountered an unexpected error” pop up during Windows install or just booting up normally, it’s pretty much a sign that Windows got stuck in a loop, often because something’s off with the registry or install files. Sometimes it’s due to corrupted media or hardware hiccups too. The weird part? Windows is kind of stubborn about fixing this on its own, so messing with the registry or media becomes necessary.

Basically, this message points to Windows thinking the setup isn’t done or that it needs to restart, which keeps it bouncing back to the same error. Fixing it usually involves telling Windows to stop obsessing over that incomplete setup flag, making sure your install media isn’t rotten, or checking if your hardware isn’t acting up. If all else fails, a clean install is the last resort, but that’s a whole other story.

How to Fix “Unexpected Restart” Error During Windows Setup

Modify the Registry to Trick Windows into Thinking Setup is Done

This method helps because the root cause is basically Windows’s registry entries being misconfigured, especially the parts that track the status of the installation. When Windows believes the setup isn’t complete, it triggers that restart loop. Applying this fix usually applies when you’re stuck in that loop after an upgrade or partial install.

Expect to see the error message pop up again after reboot, but if you’ve done it right, Windows should bypass that stuck state and proceed normally. On some setups, this fix is kinda finicky — it either works right away or needs a reboot to settle. The key step here is editing the registry with regedit from the recovery environment.

  1. On the error screen, press Shift + F10 to open the Command Prompt. If this doesn’t work, boot into recovery mode and access Command Prompt from there.
  2. Type regedit and hit Enter to launch the Registry Editor.
  3. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\Setup\Status\ChildCompletion. You can do this by expanding the folders in the left pane or pasting the path into the address bar.
  4. Find setup.exe in the right pane, double-click it, and change the value from 1 to 3. This marks that part of setup as complete.
  5. Now go to HKEY_LOCAL_MACHINE\SYSTEM\Setup.
  6. Change the values for SetupPhase, SetupType, and SystemSetupInProgress to 0—they signal that setup isn’t ongoing anymore.
  7. Find and open CmdLine in the Registry, and wipe out its string data so it’s empty.
  8. Close the Registry Editor. Click OK on the error message and see if Windows boots normally this time.

This tweak tells Windows it’s all done with setup, and—more often than not—that stops the restart hell.

Verify Your Installation Media Isn’t Trash

Found yourself reusing the same old USB or DVD? Sometimes the media itself is corrupt or doesn’t have a clean copy of Windows. Best way around this? Recreate the bootable USB using the Rufus tool. It’s straightforward and helps make sure your installation files are legit. Because of course, Windows has to make it harder than necessary, right?

If you’re using an ISO, just download a fresh copy directly from Microsoft and run it through Rufus again. That way, you’re not chasing ghosts caused by corrupted installation media.

Check Hardware: Hardware Might Be Playing Hardball

If you’re still dead in the water, hardware could be the culprit. Loose SATA cables, failing hard drives, or bad RAM can all cause weird install errors or boot loops. Sometimes, swapping out your RAM sticks or testing with a different SSD helps pinpoint hardware issues.

For hard drives, tools like Windows built-in disk check or third-party utilities can help spot bad sectors or failing disks. Also, double-check all cables and connections — it’s easy to overlook loose plugs, especially if you’re messing with hardware upgrades or reinstallations.

Last Resort: Clean Windows Install

If troubleshooting the registry, media, and hardware doesn’t work, a fresh start might be the only way. Only do this after backing up your important files — because formatting wipes everything. You’ll need a bootable Windows USB stick for this. If you don’t have one, just head over to the Microsoft media creation page and follow the instructions.

If the installer shows your drive but won’t let you install, it’s time to wipe it clean. You can do this via command prompt during setup:

  1. When you reach the “Where do you want to install Windows” screen, if possible, select your Windows partition and hit Format.
  2. Or, if you can’t see the drive, press Shift + F10 to open Command Prompt. Then run these commands to completely wipe the drive:
    diskpart list disk select disk X (replace X with your Windows disk number) clean exit

    This erases everything on that disk, so make sure nothing precious is there.

  3. Afterwards, continue with the installation and hope it goes smoothly.

Always remember: formatting wipes your data, so backup like crazy before you do this. It’s a last-ditch effort, but sometimes necessary.