Windows – Sysprep.exe fatal error, and can’t delete metro app in windows 8 to get it working

powershellsysprepwindows 8windows 8.1

Today I used sysprep.exe to rebuild my windows image. But it always said "a fatal error occurred while trying sysprep".

Then I went to check setupact.log file , it shows like this

enter image description here

I followed this instructions in Microsoft KB article , but when i execute Get-AppxPackage -AllUser in powershell, it shows plenty of apps installed by an unknown user like this

enter image description here

I can't delete them by Remove-AppxPackage . So is there any solution to remove these apps? or just delete this unknown user once and for all?

Best Answer

I figured it out by myself. I will add some key prompts to make others easy to search.

The setupact.log file will show something like this:

Error SYSPRP Package Microsoft.Internal.Media.PlayReadyClient_2.3.1678.1_x64__8wekyb3d8bbwe was installed for a user, but not provisioned for all users. This package will not function properly in the sysprep image.

And When you want to delete windows 8 apps through PowerShell, It will says that apps are installed by an unknown user, which sid is S-1-5-21-XXXX. And when you execute Remove-AppxPackage in powershell, it will says

Because the current user does not have that package installed

As far as i know, Remove-AppxPackage can only remove apps belong to the user which you log in. I don't know why there is an unknown user in my OS, but here is my solution.

  • Delete all files in C:\Program Files\WindowsApps (You need to change ownership and permission of this folder by right click on it)
  • Delete all files in C:\ProgramData\Microsoft\Windows\AppRepository (You need change the ownership too).

Now when you Get-AppxPackage -allusers, it will shows nothing. Now you can run sysprep.exe and it will work well (Remember to change HKLM\SYSTEM\Setup\Status\Sysprep\SysprepStatus to 7).

Related Question