Monday, August 11, 2014

Script / Batch file to Delete the Pending.xml from multiple servers

Hey,

Many windows servers generates Pending.xml file due to inconsistent windows updates. Due to this file, future windows updates does not get installed.

Manually deleting Pending.xml is a huge task as it has multiple steps, e.g. taking ownership of file. Adding full permissions to particulate user on that file, etc. So I thought to create a batch file which will reduce the time of administrator for this activity.

IMP : Make sure that you run this batch file with "Run As Administrator" and with the user who is having administrative permissions on the server.
Note1 : Change DOMAIN\User with the domain user with which you will delete the pending.xml file.
Note2 : Change SERVER1NAME, SERVER2NAME, etc  with the server name where the pending.xml file is present.

Copy below text and save it in PENDINGXMLDELETE.BAT file.

Have a Great Day Ahead!!!


REM Batch File Start
SET PSNO=DOMAIN\User

SET SERVER1=SERVER1NAME
SET SERVER2=SERVER2NAME
SET SERVER3=SERVER3NAME
SET SERVER4=SERVER4NAME
SET SERVER5=SERVER5NAME
SET SERVER6=SERVER6NAME


takeown /f \\%SERVER1%\c$\Windows\WinSxS\pending.xml
cacls \\%SERVER1%\c$\Windows\WinSxS\pending.xml /G %PSNO%:F
del \\%SERVER1%\c$\Windows\WinSxS\pending.xml

takeown /f \\%SERVER2%\c$\Windows\WinSxS\pending.xml
cacls \\%SERVER2%\c$\Windows\WinSxS\pending.xml /G %PSNO%:F
del \\%SERVER2%\c$\Windows\WinSxS\pending.xml

takeown /f \\%SERVER3%\c$\Windows\WinSxS\pending.xml
cacls \\%SERVER3%\c$\Windows\WinSxS\pending.xml /G %PSNO%:F
del \\%SERVER3%\c$\Windows\WinSxS\pending.xml

takeown /f \\%SERVER4%\c$\Windows\WinSxS\pending.xml
cacls \\%SERVER4%\c$\Windows\WinSxS\pending.xml /G %PSNO%:F
del \\%SERVER4%\c$\Windows\WinSxS\pending.xml

takeown /f \\%SERVER5%\c$\Windows\WinSxS\pending.xml
cacls \\%SERVER5%\c$\Windows\WinSxS\pending.xml /G %PSNO%:F
del \\%SERVER5%\c$\Windows\WinSxS\pending.xml

takeown /f \\%SERVER6%\c$\Windows\WinSxS\pending.xml
cacls \\%SERVER6%\c$\Windows\WinSxS\pending.xml /G %PSNO%:F
del \\%SERVER6%\c$\Windows\WinSxS\pending.xml


REM Batch File End

1 comment:

  1. Thank you so much for compiling this. It is EXACTLY what I needed and it worked perfectly. In my situation, I was finding a lot of "pending.xml.12345etc" files which would be old but still as problematic to delete as the regular pending.xlm files. All I had to change in the script was for it to look for "pending.xml.*" I am cautious abut deleting the regular pending.xml because I have seen it cause problems.

    ReplyDelete

Solved : The user profile failed to attach. The process cannot access the file becase it is being used by another process

Issue :  The user profile failed to attach. Please contact Support. Status : 0x0000000B, Message: Cannot open virtual disk Error Code: 0x000...