Fix: The Computer Restarted Unexpectedly or Encountered an Unexpected Error

During Windows installation or a normal startup, if you see an error message stating “The computer restarted unexpectedly or encountered an unexpected error,” it’s a sign that there’s a critical interruption in the Windows installation process, resulting in it getting stuck in a loop. While this issue can occur during normal startups, it usually relates to the Windows installation or upgrade process. When this error appears, it indicates a problem with the system that causes an unexpected restart loop during installation.

This problem is often caused by misconfigured registry entries, making Windows believe the installation process is not complete or needs a restart. Other frequent causes include corrupted Windows installation media, hardware malfunctions, or power loss during the setup process.

Now that we have discussed the main causes, let’s quickly dive into the solutions to resolve this issue.

1. Modify the Registry

When Windows mistakenly believes the installation process is incomplete, it leads to an unexpected restart. By modifying the ChildCompletion and SystemSetupInProgress registry entries appropriately, we can inform Windows that the installation is complete, prompting it to bypass any errors during installation.

  1. From the error screen, press Shift + F10 to open the Command Prompt.
  2. Type regedit and press Enter to open the Registry Editor.
  3. Navigate to the following directory and look for setup.exe in the right pane:
    HKEY_LOCAL_MACHINE\SYSTEM\Setup\Status\ChildCompletion
  4. Double-click on setup.exe and change the value data from 1 to 3.
  5. Next, go to: HKEY_LOCAL_MACHINE\SYSTEM\Setup
  6. In this location, change the value data for SetupPhase, SetupType, and SystemSetupInProgress to 0.
  7. Open the CmdLine registry entry and remove the string value data.
  8. Close the Registry Editor and check if this resolved your issue by clicking OK on the error message.

2. Verify Installation Media

Before performing a clean installation, ensure that your installation media is intact and not corrupted. This can often resolve errors occurring during factory installations. Try recreating your USB installation media using the Rufus tool.

3. Check Hardware Components

If issue persists, it’s important to check the hardware components. A faulty hard drive or other hardware parts can lead to installation problems.

  • Check all connections and try using different hardware for installation, if possible.
  • Replace or test your hard drive or SSD to rule out hardware faults.

4. Perform a Clean Installation of Windows

If all else fails, and the error persists, performing a clean installation might be necessary. This will eliminate any corrupted files from the previous installation attempts.

Before proceeding, make sure you have a bootable Windows USB drive for installation. If not, visit the official Microsoft website to download the media creation tool and follow the on-screen instructions to create a Windows installation drive. If you encounter any issues, you can refer to our guide on installing Windows via USB.

Warning: Formatting a drive using Diskpart will permanently erase all data on the selected drive. Ensure you have backed up any important files before proceeding. This action is irreversible and should only be done if you are certain that all data on the drive can be safely deleted.

  1. If you can get to the screen where you choose where to install Windows, select the drive where Windows is installed and click Format to remove all existing files.
  2. Once formatted, proceed to install Windows; hopefully, no errors will arise.
  3. If you cannot reach the screen to select the drive, press Shift + F10 to open the Command Prompt.
  4. Type the following commands to format the Windows drive:
    diskpart
    list disk
    select disk X (replace X with your Windows disk number)
    clean
    exit

  5. Once done, boot from the USB flash drive and attempt the Windows installation.

By following these steps in order, you can address the issue with a logical progression, reserving the clean installation as a last resort.

ABOUT THE AUTHOR

Hamza Mohammad Anwar


Hamza Mohammad Anwar is an intermediate JavaScript web developer with a focus on developing high-performance applications using MERN technologies. His skill set includes expertise in ReactJS, MongoDB, Express NodeJS, and other related technologies. Hamza is also a Google IT Certified professional, which highlights his competence in IT support. As an avid problem-solver, he recreates errors on his computer to troubleshoot and find solutions to various technical issues.