This is a MAJOR PITA!
Last semester's startup - I nearly about died trying to figure out what was causing it to go into this endless loop. After many hours of searching I came across a small mention by someone regarding corrupt registry, but thought nothing of it. No solutions were posted. I ended up calling up Microsoft - and lo' and behold, they had a hotfix available that fixed registry entries that would cause Win 7 sysprepped images to go bonkers. Sorry I don't have the exact KB article and I haven't touched Win 7 imaging for months - busy with other tasks.
There are a couple of posts at other forums (not sure if I can name them) but that is where credit is due.
I now have the ACTUAL SOLUTION to this problem. This solution will actually tell you exactly what registry key is causing your sysprep to fail, so then you don't have to slowly install every program until you find the problem -- especially since this didn't work for me because my problem has been intermittent.
This issue is caused by certain registry keys that are either:
a) Larger than 8kb
b) Set with incorrect permissions
c) Corrupt in some way
For me, the problem was intermittent (same registry key would sometimes cause the issue and sometimes not - must be corrupt sometimes) so it was impossible to tell what program was doing it. Luckily, there is a log you can look at that will tell you exactly what registry key is erroring out. Here are the steps for getting the log you need to see:
When you see the error message, do the following:
1.) Push Shift+F10 to get to a command prompt
2.) Navigate to C:\windows\Panther
3.) Find the Setup.etl file and find a way to copy this file off of the system (I copied it to the D:\ partition and used Ghost to gather that partition and get the file off)
4.) Copy the setup.etl file from the corrupted system to another computer that has Windows 7. Put it on the root of C:\ for easiest access.
5.) Open a Command Prompt on the Windows 7 computer.
6.) Navigate to the root of C:\ (or wherever you saved the file)
7.) Type "tracerpt setup.etl -o logfile.csv"
8.) Close the command prompt and open up logfile.csv in your text editor of choice.
9.) Look through the log file (towards the end probably) for messages that say "Failed to process reg key or one of it's decendants" For me, the exact eror looked like this: "Failed to process reg key or one of its descendants: [\REGISTRY\MACHINE\SOFTWARE\ESET\ESET Security\CurrentVersion\Plugins\01000200\Profiles\@My profile]" If you search for "reg key" or "failed to process" you should find the failure.
10.) Remove this software from your image, or find out how to get the registry key that is failing to work properly.
After this, you should be able to properly identify any problem keys and remove/workaround them on your image.
Lastly, I was using WDS and WAIK. Slow.....but free. Didn't have the time to look into other deployment methods at the time.