Windows Update cleanup after WSUS installs updates?

Windows Update cleanup after WSUS installs updates?

Postby jharris1993 » 30.11.2016, 00:04

Greetings!

One thing I have noticed with the WSUS updater is that - for whatever reason - the updater leaves Windows Update in an inconsistent state where the Windows Update functionality does not work - instead returning an error that the service is not running, despite the fact that it, and all its relevant prerequisites are indeed running. Note that I have observed this behavior on many Windows 7 machines. Since I do not use, nor do I own any Win-8 or Win-10 machines, I cannot verify how WSUS Offline Updater works there.

I have noticed this on several Win-7, 32 and 64 bit, machines and I have checked that all the relevant services are indeed working as they should.

There is a solution that has been posted up on the Windows Seven forums, and that is a batch file that resets Windows Update to a sane state. After running the batch file, everything works again. Note that these commands must be run from an elevated command prompt to work.

Suggestion:
Can this functionality be included in the WSUS updater so that after it has run, the Windows Updater is returned to a sane, usable state?

Since I cannot upload the batch file either as a batch file or as a text file, I am including it in-line.

Code: Select all
@echo off

:: Created by: Shawn Brink
:: http://www.sevenforums.com
:: Tutorial: http://www.sevenforums.com/tutorials/91738-windows-update-reset.html


set b=0

:bits
set /a b=%b%+1
if %b% equ 3 (
   goto end1
)
net stop bits
echo Checking the bits service status.
sc query bits | findstr /I /C:"STOPPED"
if not %errorlevel%==0 (
    goto bits
)
goto loop2

:end1
cls
echo.
echo Failed to reset Windows Update due to bits service failing to stop.
echo.
pause
goto Start


:loop2
set w=0

:wuauserv
set /a w=%w%+1
if %w% equ 3 (
   goto end2
)
net stop wuauserv
echo Checking the wuauserv service status.
sc query wuauserv | findstr /I /C:"STOPPED"
if not %errorlevel%==0 (
    goto wuauserv
)
goto loop3

:end2
cls
echo.
echo Failed to reset Windows Update due to wuauserv service failing to stop.
echo.
pause
goto Start



:loop3
set app=0

:appidsvc
set /a app=%app%+1
if %app% equ 3 (
   goto end3
)
net stop appidsvc
echo Checking the appidsvc service status.
sc query appidsvc | findstr /I /C:"STOPPED"
if not %errorlevel%==0 (
    goto appidsvc
)
goto loop4

:end3
cls
echo.
echo Failed to reset Windows Update due to appidsvc service failing to stop.
echo.
pause
goto Start


:loop4
set c=0

:cryptsvc
set /a c=%c%+1
if %c% equ 3 (
   goto end4
)
net stop cryptsvc
echo Checking the cryptsvc service status.
sc query cryptsvc | findstr /I /C:"STOPPED"
if not %errorlevel%==0 (
    goto cryptsvc
)
goto Reset

:end4
cls
echo.
echo Failed to reset Windows Update due to cryptsvc service failing to stop.
echo.
pause
goto Start




:Reset
Ipconfig /flushdns
del /s /q /f "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr*.dat"

cd /d %windir%\system32

if exist "%SYSTEMROOT%\winsxs\pending.xml.bak" del /s /q /f "%SYSTEMROOT%\winsxs\pending.xml.bak"
if exist "%SYSTEMROOT%\winsxs\pending.xml" (
    takeown /f "%SYSTEMROOT%\winsxs\pending.xml"
    attrib -r -s -h /s /d "%SYSTEMROOT%\winsxs\pending.xml"
    ren "%SYSTEMROOT%\winsxs\pending.xml" pending.xml.bak
)
 
if exist "%SYSTEMROOT%\SoftwareDistribution.bak" rmdir /s /q "%SYSTEMROOT%\SoftwareDistribution.bak"
if exist "%SYSTEMROOT%\SoftwareDistribution" (
    attrib -r -s -h /s /d "%SYSTEMROOT%\SoftwareDistribution"
    ren "%SYSTEMROOT%\SoftwareDistribution" SoftwareDistribution.bak
)
 
if exist "%SYSTEMROOT%\system32\Catroot2.bak" rmdir /s /q "%SYSTEMROOT%\system32\Catroot2.bak"
if exist "%SYSTEMROOT%\system32\Catroot2" (
    attrib -r -s -h /s /d "%SYSTEMROOT%\system32\Catroot2"
    ren "%SYSTEMROOT%\system32\Catroot2" Catroot2.bak
)
 
if exist "%SYSTEMROOT%\WindowsUpdate.log.bak" del /s /q /f "%SYSTEMROOT%\WindowsUpdate.log.bak"
if exist "%SYSTEMROOT%\WindowsUpdate.log" (
    attrib -r -s -h /s /d "%SYSTEMROOT%\WindowsUpdate.log"
    ren "%SYSTEMROOT%\WindowsUpdate.log" WindowsUpdate.log.bak
)
 
sc.exe sdset bits D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)
sc.exe sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)

regsvr32.exe /s atl.dll
regsvr32.exe /s urlmon.dll
regsvr32.exe /s mshtml.dll
regsvr32.exe /s shdocvw.dll
regsvr32.exe /s browseui.dll
regsvr32.exe /s jscript.dll
regsvr32.exe /s vbscript.dll
regsvr32.exe /s scrrun.dll
regsvr32.exe /s msxml.dll
regsvr32.exe /s msxml3.dll
regsvr32.exe /s msxml6.dll
regsvr32.exe /s actxprxy.dll
regsvr32.exe /s softpub.dll
regsvr32.exe /s wintrust.dll
regsvr32.exe /s dssenh.dll
regsvr32.exe /s rsaenh.dll
regsvr32.exe /s gpkcsp.dll
regsvr32.exe /s sccbase.dll
regsvr32.exe /s slbcsp.dll
regsvr32.exe /s cryptdlg.dll
regsvr32.exe /s oleaut32.dll
regsvr32.exe /s ole32.dll
regsvr32.exe /s shell32.dll
regsvr32.exe /s initpki.dll
regsvr32.exe /s wuapi.dll
regsvr32.exe /s wuaueng.dll
regsvr32.exe /s wuaueng1.dll
regsvr32.exe /s wucltui.dll
regsvr32.exe /s wups.dll
regsvr32.exe /s wups2.dll
regsvr32.exe /s wuweb.dll
regsvr32.exe /s qmgr.dll
regsvr32.exe /s qmgrprxy.dll
regsvr32.exe /s wucltux.dll
regsvr32.exe /s muweb.dll
regsvr32.exe /s wuwebv.dll
regsvr32 /s wudriver.dll
netsh winsock reset
netsh winhttp reset proxy


:Start
net start bits
net start wuauserv
net start appidsvc
net start cryptsvc
bitsadmin.exe /reset /allusers


Jim (JR)
Some see things as they are, and ask "Why?"
I dream things that never were, and ask "Why Not".

Robert F. Kennedy

“Impossible” is only found in the dictionary of a fool.
Old Chinese Proverb
jharris1993
 
Posts: 13
Joined: 13.11.2016, 02:17

Re: Windows Update cleanup after WSUS installs updates?

Postby Dalai » 30.11.2016, 01:20

jharris1993 wrote:One thing I have noticed with the WSUS updater is that - for whatever reason - the updater leaves Windows Update in an inconsistent state where the Windows Update functionality does not work [...]

I've never seen such a thing or heard of it, although I've patched a lot of systems so far, all the way from XP through 8.1. Every Windows system I install is updated by WSUS Offline, and afterwards the rest of the updates gets installed via Windows Update (since WOU doesn't contain all updates). No such issues as you describe. Did you install your systems with a modified DVD (disabled components) or something?

Regards
Dalai
Dalai
 
Posts: 1041
Joined: 12.07.2016, 21:00

Re: Windows Update cleanup after WSUS installs updates?

Postby jharris1993 » 30.11.2016, 02:17

Dalai wrote:I've never seen such a thing or heard of it, although I've patched a lot of systems so far, all the way from XP through 8.1. Every Windows system I install is updated by WSUS Offline, and afterwards the rest of the updates gets installed via Windows Update (since WOU doesn't contain all updates). No such issues as you describe. Did you install your systems with a modified DVD (disabled components) or something?


Nope.

Stock installs, or installs from the rescue partition where I knew Windows Update worked before.

I'm not sure, but I think if I take my batch script, put it into the "custom" directory, and name it "Final-something-or-other.cmd", it should run at the end of the process, right?
Some see things as they are, and ask "Why?"
I dream things that never were, and ask "Why Not".

Robert F. Kennedy

“Impossible” is only found in the dictionary of a fool.
Old Chinese Proverb
jharris1993
 
Posts: 13
Joined: 13.11.2016, 02:17


Return to Installation / Updating

Who is online

Users browsing this forum: No registered users and 10 guests