Reset Windows Update components RE: KB971058

KB 971058 talks about how to reset Windows Updates, which worked for me on a Windows Server 2012 R2 Hyper-V host that was getting error 800B001 when trying to run Microsoft Updates.

I've created a batch file that is much easier then the huge amount of steps/typing you'd need to perform otherwise. The steps are identical to the KB article.

Note this feedback from Andy, a consultant that sent me some real-world feedback:

Recently I've had cause to use it and found that the operating system does not re-create the catroot2 folder.  I found a Microsoft Community answer to the catroot2 issue here.  It references an older article discussing methods for checking for corruption and resetting it as well.

OK, well I had already applied the steps outlined in Microsoft kb971058 and the catroot2 folder was gone.  I re-created it, but found that the OS wouldn't regenerate the necessary files until the CyrptSvc was assigned the appropriate permissions by using the following command:

icacls.exe c:\windows\system32\catroot2 /grant "NT SERVICE\CryptSvc:(OI)(CI)(F)"

I submitted my experience via feedback to kb971058, but wanted to share it with you as well since I'm sure many people have used your script.  I am suggesting that the following commands should be inserted after "Ren %systemroot%\system32\catroot2 catroot2.bak"

md %systemroot%\system32\catroot2
icacls.exe c:\windows\system32\catroot2 /grant "NT SERVICE\CryptSvc:(OI)(CI)(F)"

These commands may be simpler than copying all of the files to the backup directory, then removing all files and subfolders.