Данный скрипт предназначен для решения проблем с установкой обновлений на ОС Windows. Он производит очистку и перерегистрацию основных служб, при запуске потребует повышения привилегий.
@ECHO OFF
VER |>NUL FIND /v "5." && IF "%~1"=="" (
ECHO CreateObject^("Shell.Application"^).ShellExecute WScript.Arguments^(0^),"1","","runas",1 >"%temp%\Elevating.vbs"
cscript.exe //nologo "%temp%\Elevating.vbs" "%~f0"& GOTO :EOF
)
DEL /s /q /f "%temp%\Elevating.vbs" > nul 2>&1
ECHO.
ECHO Do you want to reset Windows Update service on your computer?
ECHO.
SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO :EOF
ECHO.
ECHO 1. Stopping Windows Update Services...
bitsadmin /reset
sc config bits start=disabled
net stop bits
ECHO Checking the Background Intelligent Transfer Service status.
sc query bits | findstr /I /C:"STOPPED"
IF NOT %errorlevel%==0 (
ECHO Failed to stop the Background Intelligent Transfer Service.
sc config bits start=delayed-auto
PAUSE
GOTO :EOF
)
sc config wuauserv start=disabled
net stop wuauserv
ECHO Checking the Windows Update AutoUpdate Service status.
sc query wuauserv | findstr /I /C:"STOPPED"
IF NOT %errorlevel%==0 (
ECHO Failed to stop the Windows Update AutoUpdate Service.
sc config bits start=delayed-auto
sc config wuauserv start=demand
PAUSE
GOTO :EOF
)
net stop appidsvc
ECHO Checking the Application Identity Service status.
sc query appidsvc | findstr /I /C:"STOPPED"
IF NOT %errorlevel%==0 (
ECHO Failed to stop the Application Identity Service.
sc config bits start=delayed-auto
sc config wuauserv start=demand
PAUSE
GOTO :EOF
)
net stop cryptsvc
ECHO Checking the Cryptographic Service status.
sc query cryptsvc | findstr /I /C:"STOPPED"
IF NOT %errorlevel%==0 (
ECHO Failed to stop the Cryptographic Service.
sc config bits start=delayed-auto
sc config wuauserv start=demand
PAUSE
GOTO :EOF
)
ECHO.
ECHO 2. Remove QMGR Data file...
DEL /s /q /f "%ALLUSERSPROFILE%\Microsoft\Network\Downloader\qmgr*.dat"
DEL /s /q /f "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr*.dat"
ECHO.
ECHO 3. Renaming the Software Distribution and CatRoot Folder...
CD /d %windir%\system32
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
)
ECHO.
ECHO 4. Removing old Windows Update log and pending updates...
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
)
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
)
ECHO.
ECHO 5. Resetting the Windows Update Services to defualt settings...
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)
ECHO.
ECHO 6. Registering some DLLs...
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.exe /s wudriver.dll
ECHO.
ECHO 7. Removing WSUS client settings...
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v LastRestorePointSetTime /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientId /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientIdValidation /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v AccountDomainSid /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v PingID /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v BranchReadinessLevel /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v DeferFeatureUpdatesPeriodInDays /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v DeferQualityUpdatesPeriodInDays /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v DeferUpdatePeriod /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v DeferUpgradePeriod /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v ExcludeWUDriversInQualityUpdate /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v PauseDeferrals /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v PauseFeatureUpdates /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v PauseQualityUpdates /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v BranchReadinessLevel /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v DeferFeatureUpdatesPeriodInDays /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v DeferQualityUpdatesPeriodInDays /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v ExcludeWUDriversInQualityUpdate /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v DeferUpgrade /f
ECHO.
ECHO 8. Resetting the WinSock...
netsh winsock reset
netsh winhttp reset proxy
ipconfig /flushdns
ECHO.
ECHO 9. Starting Windows Update Services...
sc config bits start=delayed-auto
sc config wuauserv start=demand
net start cryptsvc
net start appidsvc
net start bits
net start wuauserv
ECHO.
ECHO 10. Forcing discovery updates...
wuauclt /resetauthorization /detectnow
ECHO.
ECHO 11. Removing SoftwareDistribution.bak directory...
RD %SYSTEMROOT%\SoftwareDistribution.bak /S /Q >NUL
ECHO.
ECHO Task completed sucessfully!
ECHO.
SET /P AREYOUSURE=Do you want to restart your computer (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO :EOF
shutdown -r -t 0
Комментариев нет:
Отправить комментарий