How do I recover from "repair pending" error in SFC?

I am trying to fix an issue with Windows registry and services. I tried running sfc command but this is the error message I get?

C:\Windows>sfc /scannow

Beginning system scan.  This process will take some time.    

There is a system repair pending which requires reboot to complete.  Restart
Windows and run sfc again.

C:\Windows>

But I have rebooted several times since this message first appeared, and I even tried running the command in safe mode and in console mode but I still get the same message. How do I get rid of it?

There is this file in winsxs folder: C:\Windows\winsxs\cleanup.xml

This is it's content:

<?xml version='1.0' encoding='utf-16'?>
<PendingTransaction >
    <POQ postAction="NoReboot">
        <DeleteFile path="\??\D:\$$DeleteMe.CbsMsg.dll.01c85bd2f5893b40.0000"/>
    </POQ>
</PendingTransaction>

Could this be something? Is this the cause? Is it safe to delete this file?

Update

I tried renaming it but the operation failed.

I ran the explorer.exe with elevated privileges and navigated to the location. I got the UAC confirmation prompt and then the error below.

Destination Folder Access Denied
You need permission to perform this action

How do I rename or delete this file? Do I need to use cmd or be in safe mode to do it?

Update 2

I started safe mode with command prompt and tried taking ownership of the file and then renaming it. Rename failed.

C:\Windows\winsxs>ren cleanup.xml cleanup.xml.old
Access is denied.

C:\Windows\winsxs>takeown /f "cleanup.xml"

SUCCESS: The file (or folder): "C:\Windows\winsxs\cleanup.xml" now owned by user
 "mycomputername\username".

C:\Windows\winsxs>ren cleanup.xml cleanup.xml.old
Access is denied.

C:\Windows\winsxs>

I also issued following command.

C:\Windows\system32>icacls "C:\Windows\winsxs\cleanup.xml" /grant username:F
processed file: C:\Windows\winsxs\cleanup.xml
Successfully processed 1 files; Failed processing 0 files

C:\Windows\system32>cd ..\winsxs

C:\Windows\winsxs>ren cleanup.xml cleanup.xml.old
Access is denied.

C:\Windows\winsxs>

It still won't allow me to rename it. I issued these last two commands in normal Windows mode. Does it matter?... I will try a reboot.


I have the same issue in Windows 7. I finally got sfc to run using the following commands from the repair console (for some reason, it assigned D: to my main disk, rather than C:)

del d:\windows\winsxs\pending.xml
del x:\windows\winsxs\pending.xml
sfc /scannow /offbootdir=D:\ offwindir=D:\Windows

(However, sfc now tells me

Windows Resource Protection found corrupt files but was unable to fix some of them.

so this did not fix my startup issues)


This command is supposed to do it.

dism.exe /image:C:\ /cleanup-image /revertpendingactions

But this only works in Windows 7 or newer. I don't have the dism.exe tool in Windows Vista. I just thought I would share it with those who find this question and who do have Windows 7. I was of course unable to test this myself, but this guy says he was able to remove this annoying error message out of the world. So it might be worth a try.