One of the benefits of WinPE is that it allows you to work with an offline operating system without the problems of files being in use. This is most evident when it comes to Defragging a hard drive. Many files such as the pagefile or the regsitry hives cant be defragmented when they are in use. Thankfully this task can still be accomplished with PE with the right modifications.
By adding these registry keys to your PE and then the files you will have the full capabilities of defrag inside of your PE.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\EXTERNALSOFTWARE\Classes\CLSID\{80EE4901-33A8-11d1-A213-0080C88593A5}]
@="Defrag NTFS engine"
[HKEY_LOCAL_MACHINE\EXTERNALSOFTWARE\Classes\CLSID\{80EE4901-33A8-11d1-A213-0080C88593A5}\LocalServer32]
@=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,44,00,66,00,\
72,00,67,00,4e,00,74,00,66,00,73,00,2e,00,65,00,78,00,65,00,00,00
[HKEY_LOCAL_MACHINE\EXTERNALSOFTWARE\Classes\CLSID\{80EE4902-33A8-11d1-A213-0080C88593A5}]
@="Defrag FAT engine"
[HKEY_LOCAL_MACHINE\EXTERNALSOFTWARE\Classes\CLSID\{80EE4902-33A8-11d1-A213-0080C88593A5}\LocalServer32]
@=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,44,00,66,00,\
72,00,67,00,46,00,61,00,74,00,2e,00,65,00,78,00,65,00,00,00
For these files you can copy them from a Vista machine but make sure that the Vista service pack version matches the WinPE service pack version. Place them in the same locations as they are located on Vista.
System32\Defrag.exe
System32\dfrgfat.exe
System32\DfrgNtfs.exe
System32\DfrgRes.dll
System32\en-US\Defrag.exe.mui
System32\en-US\DfrgFat.exe.mui
System32\en-US\DfrgNtfs.exe.mui
System32\en-US\DfrgRes.dll.mui