Update. As Avi pointed out in comments to this post, my script does not handle root directories that invalid in Windows FileSystem space, because FSO does not see them when enumerating. I changed it to call of "DIR" command. And now I just delete them.
Another minor (but important!) change was taking out skipping deletion of "RECYCLER" folder from the script. I got a case of invalid names under RECYCLER. Please use at your own risk.

 

If you've been doing XP to Wind 7 migrations in larger scale, you probably came across some computers out there that ended up tossed with NTLD missing error.

Not nice! After this happens, you'd probably boot and safe user's data from state store, and try to figure out what the hack happened. Looking in smsts.log reveals some details:


Reporting deletion progress.
Unable to delete directory C:\Documents and Settings\***\Local Settings\Temp\OICE_43BCF28F-9C21-4A31-BC1E-52B54828BD6F.0 (0x80070091). Continuing.
Unable to delete directory C:\Documents and Settings\***\Local Settings\Temp\OICE_930D53AE-2288-434E-97DD-C56505BB49CA.0 (0x80070091). Continuing.
Unable to delete directory C:\Documents and Settings\***\Local Settings\Temp (0x80070091). Continuing.
Unable to delete directory C:\Documents and Settings\***\Local Settings (0x80070091). Continuing.

Searching on the internet is giving you some clue. Most of the posts saying it's permissions, so you come up with the script that resets permissions, but this is still happening. 

So what's the culprit?

Let's see what in that folder.

 Directory of C:\Documents and Settings\***\Local Settings\Temp

02/14/2012 05:50 PM <DIR> .
02/14/2012 05:50 PM <DIR> ..
02/14/2012 05:50 PM <DIR> OICE_1ED1F44B-623B-49CB-91A9-3D5FF12339E9.0
02/14/2012 05:50 PM <DIR> OICE_450CAED0-70C4-4B0E-A799-4C20309918BE.0
0 File(s) 0 bytes

Directory of C:\Documents and Settings\***\Local Settings\Temp\OICE_1ED1F44B-623B-49CB-91A9-3D5FF12339E9.0

02/14/2012 05:50 PM <DIR> .
02/14/2012 05:50 PM <DIR> ..
02/13/2012 07:28 PM 0 108D235B.
1 File(s) 0 bytes

Directory of C:\Documents and Settings\***\Local Settings\Temp\OICE_450CAED0-70C4-4B0E-A799-4C20309918BE.0

02/14/2012 05:50 PM <DIR> .
02/14/2012 05:50 PM <DIR> ..
02/13/2012 06:12 PM 0 FE182149.
1 File(s) 0 bytes

Total Files Listed:
2 File(s) 0 bytes
8 Dir(s) 300,889,800,704 bytes free

Notice highlighted files. They got a dot at the end. 

Bingo! Look at this answer:

http://stackoverflow.com/questions/4075753/how-to-delete-a-folder-that-name-ended-with-a-dot
 

Looks like OSDApplyOS does not use it to delete files, so we're in trouble.

So what creates it? I have a guess. 

Looks like it's related somehow with Office Isolated Conversion Environment. So, 

http://support.microsoft.com/kb/935865 

I attached the script you can run if Apply OS Image failed before running Apply OS Image again.

Quick illustration:

How to use this script

 

This script needs ztiutility.vbs from MDT and it needs setacl.exe from http://sourceforge.net/projects/setacl/files/ 

If you use MDT, I recommend creating a Custom folder under Scripts on MDT package and copying the script and SetACL.exe into it.

 

Only If you DON'T use MDT change path to ZTIUtility from parent folder to current folder in the script

<script language="VBScript" src="..\ZTIUtility.vbs"/>

to

<script language="VBScript" src="ZTIUtility.vbs"/>

Copy SetAcl.exe, ZTIUtility.vbs and the script to a separate package in Configuration Manager.

 

  1. Open your task sequence
  2. Find "Apply Operating System Image" step
  3. Go to options and select "Continue on error"
  4. Create a new group, call it "Image Failed to Apply" right below the "Apply Operating System Image" step
  5. Add a new step of type "Run Command Line" to your new group
  6. If you use MDT and followed recommendation to copy it to Scripts\Custom use this command line: cscript.exe "%DeployRoot%\Scripts\Custom\OSDApplyOSRecovery.wsf"
  7. If you're using a separate package, just use this command line: cscript.exe "OSDApplyOSRecovery.wsf" and Check "Package" and point it to the package you created above.
  8. Call this step "Attempt to recover"
  9. Go to options and set "Continue on error"
  10. Copy "Apply Operating System Image" step and paste it under your "Attempt to Recover" step.
  11. If you're using MDT template, you should see "Logical drive letter stored under variable" under Destination. No changes necessary.
  12. If you're not using MDT, and it says "Next Available Partition" you should change it to Specific Disk and Partition and use a proper partition (usually partition 2 disk 0 if formatting for bitlocker)
  13. Go to options and unselect "Continue on error" only for that step
  14. Done! :)

TEST, TEST AND TEST

Try to create an "invalid" folder by using mkdir "\\?\C:\Screw my deployment with period at the end."

 Set permissions on it removing  Local System and administrators. Start OS Refresh.

 Be careful with this script if you save your State Store somewhere else but \StateStore folder! Meaning - if you're running MDT 2010 U1 or earlier integration and pick and alternative location for State Store other then C:\StateStore!
Thank you.