Sysprep - Fatal error occurred while trying to sysprep the machine

10-11  Source: Network gathering  Views:7 

On the 4th attempt to sysprep a Windows 7 Enterprise system, I get the dreaded, 'A fatal error occurred while trying to sysprep the machine.' 
The setuperr.log shows:
2010-08-04 13:57:58, 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
2010-08-04 13:57:58, Error      [0x0f00ae] SYSPRP WinMain:Hit failure while processing sysprep cleanup external providers; hr = 0x8007001f
I've seen articles referring to the Windows Software Licensing Rearm program may have issues running more than three times in a single Windows image and to add <SkipRearm>1</SkipRearm> in the /unattend file...  but this did not help. 
The Windows Media Player Network Sharing Service has also been disabled which is often referred to in other posts.
The KB article: indicated that the resolution is to re-create the image for the machine... This is very frustrating. I'm hoping that there is
a better resolution???
How do you sysprep a machine more than three times to avoid this error?
I had a problem Where Runing slmgr /dlv returned 0 and could not sysprep a
32 bit Win 7 Installed on C:drive
Here is what I did to succeed whit Sysprep.
Disable UAC
Based on
This :
open notepad and copy paste the following:
setLocal Enabledelayedexpansion
for %%d in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
  if exist %%d:\windows\system32 (
     SET drv1=%%d:\windows\system32
    reg load HKLM\MY_SYSTEM !drv1!
    reg delete HKLM\MY_SYSTEM\WPA /f
    reg unload HKLM\MY_SYSTEM
ECHO Done, Rebooting system...
timeout 3
wpeutil reboot
Then in notepad chose file>save as, in File Type select "All Files", name it "c:\reset.bat"
Reboot Your Pc, after bios screen press F8, Select "Repair Your Computer", select your keyboard layout, enter your credentials if needed,
then select the last option "Open Command Prompt"
type "c:\reset.bat" or "d:\reset.bat" (Sometimes Your Windows Partition get a different letter on the repair environment)
Back on Windows follow step five if needed.
Check under slmgr /dlv you have more than 0 under "Remaining Windows Rearm count"
Download from
here, extract content an copy psexec.exe to %windir%\System32
run psexec.exe and accept the license agreement so it won't bother when running afterwards, close it.
open notepad and copy paste the following:
echo Stopping Windows Media Player Sharing Service..
net stop wmpnetworksvc
echo Deleting Old Sysprep Logs...
del /f /s /q %windir%\System32\sysprep\panther\*.*
echo Adding Required Sysprep Registry Keys...
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v SkipRearm /t REG_DWORD /d 00000001 /f
REG ADD HKLM\SYSTEM\Setup\Status\SysprepStatus /v GeneralizationState /t REG_DWORD /d 00000007 /f
REG ADD HKLM\SYSTEM\Setup\Status\SysprepStatus /v CleanupState /t REG_DWORD /d 00000002 /f
psexec -i -s REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Sysprep\Cleanup /v "{EC9FE15D-99DD-4FB9-90D5-5B56E42A0F80}" /t REG_SZ /d "C:\\Windows\\System32\\iesysprep.dll,Sysprep_Cleanup_IE" /f
psexec -i -s REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Sysprep\Generalize /v "{EC9FE15D-99DD-4FB9-90D5-CE53C91AB9A1}" /t REG_SZ /d "C:\\Windows\\System32\\iesysprep.dll,Sysprep_Cleanup_IE" /f
psexec -i -s REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Sysprep\Specialize /v "{EC9FE15D-99DD-4FB9-90D5-676C338DC1DA}" /t REG_SZ /d "C:\\Windows\\System32\\iesysprep.dll,Sysprep_Cleanup_IE" /f
echo Uninstalling MSDTC...
msdtc -uninstall
timeout 10
echo Reinstalling MSDTC...
msdtc -install
timeout 10
echo Cross Your Fingers, Finally Running Sysprep...
%windir%\System32\sysprep\sysprep /generalize /oobe /shutdown /unattend:unattend.xml
Change Last Line to suit your needs, ie: if you are not using an unnattend answer file, then delete /unattend:unattend.xml"
Then in notepad chose file>save as, in File Type select "All Files", name it "%windir%\System32\do.cmd"
if you use an unattend.xml file copy it to %windir%\System32\sysprep folder.
Once you are ready run %windir%\System32\do.cmd
Hope it helps,
Related articles