I have a script that runs in WinPE that takes a system drive with Windows installed and deletes everything off of the drive (keeping the filesystem intact).
When dealing with a Windows XP/Vista/7 installation it functions properly. attrib -S -A -H -I -R /S /D \
is run, and then everything is deleted.
However, within Windows 8, I run into an "Access Denied" error. For some reason, even as the SYSTEM user within WinPE, I can't edit the directory C:\ProgramData\Microsoft\Windows\LocationProvider
. I can't use attrib
to set attributes, I can't delete it - I can't even cd
into it! dir /a
just returns File Not Found
.
Using rmdir /S /Q
gives me the "Access Denied" error.
Assuming that the problem is related to permissions and/or ownership, you can work around it using the built-in robocopy
tool - luckily, this is included in Windows PE.
First, create an empty directory, e.g., x:\empty
and then run
robocopy /e /purge /b x:\empty c:\
The /b
flag tells robocopy to use backup mode, which bypasses security.