WordPress theme update fails with ‘Could not remove the old theme..’

I finally got round to updating WordPress to version 3.4.2. This went smoothly. I then tried to update the Twenty Eleven and Twenty Ten themes to version 1.4 and was met with the following error:

An error occurred while updating Twenty Eleven: Could not remove the old theme..

A screenshot of the error is below:

We can see that the updates downloaded successfully so we know that the IIS worker process has write permissions. The updates failed at the ‘removing the old version of the theme stage’ which indicated that the IIS worker process did not have permissions to delete the \themes\twentyeleven folder.

A quick check confirmed this. So I added the modify permissions for the IIS worker process account to the themes folder:

I then re-ran the theme update process and it was successful because the IIS worker process was able to delete the older Twenty Eleven theme folder:

I now have up-to-date WordPress themes. The same principle applies for plugin updates – just modify the relevant plugin directory and give the IIS worker process modify permissions and updates will run successfully.