FIX: SysPrep Fatal error: dwRet = 31, Machine is in an invalid state or we couldn't update the recorded state.

If you try to run Sysprep on Windows, more than three (3) times, then you will receive the following error message "A fatal error occurred while trying to Sysprep the machine" and the following explanation message is displayed inside the sysprep error log file (setuperr.log): "Date Time, Error [0x0f0073] SYSPRP RunExternalDlls:Not running DLLs; either the machine is in an invalid state or we couldn't update the recorded state, dwRet = 31".

sysprep-fatal-error dwRet = 31

Microsoft says that this error message "is designed to prevent the deployment of a corrupted image", but this is not true, because the error was caused when you reached the three rearm limit (you cannot run sysprep more than three times on the same machine).

In this tutorial you will find detailed instructions on how you can Sysprep your Windows 7, 8 or 10 machine more than three times and bypass the "Date Time, Error [0x0f0073] SYSPRP RunExternalDlls:Not running DLLs; either the machine is in an invalid state or we couldn't update the recorded state, dwRet = 31" fatal error while running Sysprep.


How to fix SysPrep Fatal error "dwRet = 31" and Sysprep your machine more than three (3) times.


Step 1. Modify SysprepStatus, CleanupState & SkipRearm Registry Values

1. Open Windows Registry Editor. To do that:

  1. Press “WindowsImage-201_thumb_thumb_thumb_thumb1_t  + “R” keys to load the Run dialog box.
  2. Type “regedit” and press Enter.


IMPORTANT: Before you continue to modify the registry, first take a registry backup. To perform a registry backup:

a. From the main menu, go to File & select Export.
b. Specify a destination location (e.g. your Desktop), give a filename (e.g. “RegistryBackup”) and press Save.

2. Inside Windows Registry, navigate (from the left pane) to this key:




3a. At the right pane change the CleanupState value to 2 and click OK.

SysPrep dwRet 31


3b. Change the GeneralizationState value to 7 and click OK.



4. At the left pane navigate to the following key:


sysprep more than trhee (3) times


5. At the right pane, change the SkipRearm value to 1.



6. Close Registry Editor.


Step 2. Uninstall and then re-install the MDSTC service (Microsoft Distributed Transaction Coordinator)


1. Open command prompt with Administrative privileges. To do that:

In Windows 7 & Vista go to:

  • Start > All Programs > Accessories
  • Right-click to “Command prompt” item and choose “Run as administrator”.

command prompt run as administrator


In Windows 10, 8 & 8.1:

  • Right-click at the screen's bottom-left corner (Start menu) and from the pop-up menu, choose “Command Prompt (Admin)”.



2. In command prompt window type the following command and press Enter to uninstall the MSDTC service:

msdtc –uninstall

msdtc –uninstall


3. Then re-install the MSDTC service by typing the following command (and press Enter).

msdtc –install

msdtc –install


4. Close command prompt.


Step 3. Delete the Panther folder.

1. Open Windows Explorer and navigate to C:\Windows\System32\sysprep\ folder.

2. Delete (or Rename) the Panther folder.



3. Now run sysprep again. Sysprep should run now without any problems.

You 're done! Let me know if this guide has helped you by leaving your comment about your experience. Please like and share this guide to help others.

If this article was useful for you, please consider supporting us by making a donation. Even $1 can a make a huge difference for us in our effort to continue to help others while keeping this site free: