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".
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:
2. Inside Windows Registry, navigate (from the left pane) to this key:
HKEY_LOCAL_MACHINE\System\Setup\Status\SysprepStatus
3a. At the right pane change the CleanupState value to 2 and click OK.
3b. Change the GeneralizationState value to 7 and click OK.
4. At the left pane navigate to the following key:
HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\SoftwareProtectionPlatform
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”.
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
3. Then re-install the MSDTC service by typing the following command (and press Enter).
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.
We're hiring
We're looking for part-time or full-time technical writers to join our team! It's about a remote position that qualified tech writers from anywhere in the world can apply. Click here for more details.
- How to Backup Synology NAS to External USB Drive. - December 11, 2023
- How to Send Automatic Replies in Outlook with an Office365/Exchange Account. - December 6, 2023
- How to Send Automatic Replies in Outlook with POP3/IMAP Accounts. - December 4, 2023
June 22, 2021 @ 4:42 am
Unlike EVERYONE else in this article, I am still getting a 0x00004005 immediately when I start SYSPREP. Before anyone asks, no, there are no app pkgs referenced in either logs. I have been searching all day for a solution to this and have only found these directions over and over and over again. Although, this one was the first one that said to delete/rename the Panther folder. I thought that must be it. Alas, this apparently unsolvable problem still exists. If anyone can point me in the correct direction, that would be much appreciated. Thank you.
March 14, 2020 @ 7:36 pm
This is amazing, thank you for saving my day!
October 31, 2019 @ 3:55 am
Great write-up! What does the MSDTC section do? I am able to clear the error without changing MSDTC.
August 16, 2019 @ 3:50 pm
YESSSSS ! it works. Thank you very much..
July 25, 2019 @ 11:54 pm
Buddy, i'm really really so glad that i found your article, you saved alot of time and effort
thanks alot buddy, with you best of wishes
June 5, 2019 @ 10:25 am
Help me to avoid jump out the window(s). You are a hero. I'm looking now daily at your website.
Greetings from Germany
September 24, 2018 @ 12:24 pm
After two days of fighting with this problem your page has arrived with the perfect solution.
Thanks.
September 29, 2018 @ 12:35 pm
Great solution, it is working in Windows 2008 R2 also. One step missed here is, we need to restart the machine, after that we can perform sysprep operation smoothly.
September 10, 2018 @ 11:44 am
Great, saved my day :)
August 30, 2018 @ 9:45 pm
It's ridiculous that this still happens to Windows 10 in 2018. I do wonder how many of the commentators here had this happen on an HP machine? I saw this on an HP EliteDesk 800 G3 Mini, but I've also seen reports from various other HP models. The one common denominator seems to be the "Allow PCIe/PCI SERR# Interrupt" setting in the BIOS. Disable that and sysprep works fine. I blame both Microsoft and HP in equal measure for allowing this bug to persist for so many years. It's inexcusable.
August 3, 2018 @ 3:40 pm
Whoever wrote this, must be a saint!
Gratitude!
July 26, 2018 @ 4:32 pm
Had this Problem under Win10 1803. Many thanks!!!!!!!!!
This helped a lot!
July 12, 2018 @ 7:12 pm
Thank you very much!!
June 18, 2018 @ 10:35 pm
TY SO FUCKING MUCH…
THE BEST TUTORIAL TO FIX SHITPREP.
June 5, 2018 @ 4:46 pm
Unbelievable! It's working! Thank you very much
May 18, 2018 @ 5:57 am
You r genius……………..
April 25, 2018 @ 7:52 am
Thank you , it worded for me.
January 11, 2018 @ 2:32 am
Excellent document
Many thanks
November 13, 2017 @ 12:45 pm
Worked perfectly for me too, nice one.
November 9, 2017 @ 4:15 pm
A complete walkthru for solving this problem. Thank you for sharing.
August 30, 2017 @ 3:16 am
Anda joya muchas gracias…
July 18, 2017 @ 9:26 pm
Thank you!! very helpful!
July 14, 2017 @ 3:45 pm
Brilliant! Thank you.
Saved me from starting all over with an image.
July 6, 2017 @ 5:23 pm
I did all the steps up until, "part one fixing boot filenon MBR" (step 1)
I cant find any file that says window in any disk. Does this means my windows really did gone missing?
How do did it happen and how do i fix this?
July 6, 2017 @ 7:50 pm
@Shafiq Kamarudin: I think that you wrote your comment in a wrong article.
June 6, 2017 @ 5:43 pm
Thanks, that did the trick!
February 19, 2017 @ 2:37 pm
Thanks, after trying everything this worked for me.
The only extra thing I needed to do after following this tutorial to get it working was to disable windows media player through cmd (admin privs) with the command 'net stop WMPNetworkSvc'.
February 14, 2017 @ 11:03 pm
thanks !
February 9, 2017 @ 6:40 pm
Sweet fix, thank you
January 26, 2017 @ 3:02 am
Worked for me as well! Thanks!!
November 15, 2016 @ 6:35 pm
Nice, instructions. Got my sysprep running again. Thanks!
September 30, 2016 @ 10:21 pm
Awesome!! that helped alot.
September 18, 2016 @ 8:20 pm
Thank You So Much! This saved me so much time!