Back to Technology
Batch File To Aid In Troubleshooting Windows Update Issues

By: Gordon Rankine
Published: 10 Apr 2014 20:00

When you are patching numerous Windows servers with Windows Updates via WSUS, sometimes you encounter a few servers that either do not pull any updates down from the WSUS server or just loop when trying to install updates.

There are various solutions online that recommend renaming folders, stopping services etc. I have put these solutions into a batch file to speed up this process.

The first batch file works for Server 2008 & 2008R2. Just copy the code, paste it into notepad and save it as a .bat file. If you have UAC enabled, right click the batch file and select Run As Administrator.

@echo off

Title Server 2008 WSUS Fix

echo Ensure you run this batch file with Administrator privledges.

echo 1. Run WSUS Fix
echo 2. Exit
set /p choice=Please choose a task:
set choice=%choice:~0,1%
if "%choice%"=="1" goto start
if "%choice%"=="2" goto exit
echo Invalid choice, please try again.
goto choice

gpupdate /target:computer /force
goto proxy

netsh winhttp reset proxy > nul
goto service_stop

net stop wuauserv
goto service_start

net start wuauserv
goto check_for_updates

wuauclt /detectnow /resetauthorization
goto wuapp

goto exit


The second batch file works for Server 2003R2. Just copy the code, paste it into notepad and save it as a .bat file.

REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientIdValidation /f
net stop "Automatic Updates"
move %windir%\windowsupdate.log %windir%\windowsupdate.old.log
move %windir%\SoftwareDistribution %windir%\SoftwareDistributionold
regsvr32 /s atl.dll
regsvr32 /s wucltui.dll
regsvr32 /s wups.dll
regsvr32 /s wuaueng.dll
regsvr32 /s wuapi.dll
regsvr32 /s msxml3.dll
regsvr32 /s mssip32.dll
regsvr32 /s initpki.dll
regsvr32 /s softpub.dll
net start "Automatic Updates"
wuauclt /resetauthorization /detectnow

Please note, in some cases the server will required a reboot to pull the updates down.

If you use VMWare and deploy a lot of virtual machines from templates then these batch files will come in very handy indeed.

Disclaimer: This script is provided as is without any warranty. You are responsible for running this script and I will not be held accountable for any data loss or issues arising from this script.

Add Comment

Batch Files   Windows Updates   WSUS   Windows Server   Scripts

Back to Technology