Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: ==================================================================================
- :: NAME : Reset Windows Update Components.
- :: DESCRIPTION : This script reset the Windows Update Components.
- :: AUTOR : Manuel Gil.
- :: VERSION : 8.0.
- ::
- :: http://windowsitpro.com/powershell/cool-tool-script-selectively-fix-common-windows-update-problems
- :: https://gallery.technet.microsoft.com/scriptcenter/Reset-Windows-Update-Agent-d824badc
- :: ==================================================================================
- :: CMD Screen Settings.
- :: /************************************************************************************/
- echo off
- title Reset Windows Update Components.
- color 17
- cls
- :: /************************************************************************************/
- :: Checking for Administrator elevation.
- :: /************************************************************************************/
- openfiles>nul 2>&1
- if %errorlevel%==0 goto Variables
- cls
- ver
- echo Reset Windows Update Components Tool.
- echo.
- echo Checking for Administrator elevation.
- echo.
- echo You are not running as Administrator.
- echo This batch cannot do it's job without elevation.
- echo.
- echo You must run this tool as Administrator.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Close
- :: /************************************************************************************/
- :: Set variables.
- :: /************************************************************************************/
- :Variables
- set version=0.0.0000
- set name=Windows
- set allow=0
- for /f "tokens=4-5 delims=[] " %%a in ('ver') do set version=%%a %%b
- for %%a in (%version%) do set version=%%a
- if %version%==5.1.2600 (
- set name=Windows XP
- set allow=1
- )
- if %version%==5.2.3790 (
- set name=Windows XP Professional x64 Edition
- set allow=1
- )
- if %version%==6.0.6000 (
- set name=Windows Vista
- set allow=1
- )
- if %version%==6.0.6001 (
- set name=Windows Vista SP1
- set allow=1
- )
- if %version%==6.0.6002 (
- set name=Windows Vista SP2
- set allow=1
- )
- if %version%==6.1.7600 (
- set name=Windows 7
- set allow=1
- )
- if %version%==6.1.7601 (
- set name=Windows 7 SP1
- set allow=1
- )
- if %version%==6.2.9200 (
- set name=Windows 8
- set allow=1
- )
- if %version%==6.3.9200 (
- set name=Windows 8.1
- set allow=1
- )
- if %version%==6.3.9600 (
- set name=Windows 8.1 Update 1
- set allow=1
- )
- if %version%==10.0.10240 (
- set name=Windows 10
- set allow=1
- )
- if %version%==10.0.10565 (
- set name=Windows 10 Insider
- set allow=1
- )
- cls
- ver
- echo Reset Windows Update Components Tool.
- echo.
- echo Microsoft %name% detected . . .
- -echo.
- if %allow%==0 echo Sorry, this Operative System is not compatible whit this tool.
- if %allow%==1 goto Terms
- echo.
- echo An error occurred while attempting to verify your system.
- echo Can this using a business or test version.
- echo.
- echo If not, verify that your system has the correct security fix.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Close
- :: /************************************************************************************/
- :: Terms.
- :: /*************************************************************************************/
- :Terms
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo The methods inside this batch modify files and registry settings.
- echo While they are tested and tend to work, I take no responsibility for
- echo the use of this file.
- echo This batch is provided without warranty. Any damage caused is your
- echo own responsibility.
- echo.
- echo As well, batch files are almost always flagged by anti-virus, feel free
- echo to review the code if you're unsure.
- echo.
- choice /c YN /n /m "Do you want to continue with this process? (Yes/No) "
- if %errorlevel%==1 goto Menu
- if %errorlevel%==2 goto Close
- echo.
- echo An unexpected error has occurred.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Close
- :: /*************************************************************************************/
- :: Menu of tool.
- :: /*************************************************************************************/
- :Menu
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo 1. Change invalid values in the Registry.
- echo 2. Reset Windows Update Components.
- echo 3. Delete temporary files in Windows.
- echo 4. Open the Internet Explorer options.
- echo 5. Reset the Winsock settings.
- echo 6. Search updates.
- echo 7. Explore other local solutions.
- echo 8. Explore other online solutions.
- echo 9. Restart your PC.
- echo 0. Close.
- echo.
- set /p Opcion= Select an option:
- if %Opcion%==1 goto Regedit
- if %Opcion%==2 goto Reset
- if %Opcion%==3 goto Temp
- if %Opcion%==4 goto Historic
- if %Opcion%==5 goto Winsock
- if %Opcion%==6 goto Search
- if %Opcion%==7 goto Local
- if %Opcion%==8 goto Online
- if %Opcion%==9 goto Restart
- if %Opcion%==0 goto Close
- echo.
- echo Invalid option.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Menu
- :: /*************************************************************************************/
- :: Change invalid values.
- :: /*************************************************************************************/
- :Regedit
- for /f "tokens=1-5 delims=/, " %%a in ("%date%") do (
- set now=%%a%%b%%c%%d%time:~0,2%%time:~3,2%
- )
- :: ------------------------------------------------------------------------
- :: Create a backup of the Registry.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Making a backup copy of the Registry in: %USERPROFILE%\Desktop\Backup%now%.reg
- echo.
- if exist "%USERPROFILE%\Desktop\Backup%now%.reg" (
- echo An unexpected error has occurred.
- echo.
- echo Changes were not carried out in the registry.
- echo Will try it later.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Menu
- ) else (
- regedit /e "%USERPROFILE%\Desktop\Backup%now%.reg"
- )
- :: ------------------------------------------------------------------------
- :: ------------------------------------------------------------------------
- :: Checking backup.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Checking the backup copy.
- echo.
- if not exist "%USERPROFILE%\Desktop\Backup%now%.reg" (
- echo An unexpected error has occurred.
- echo.
- echo Something went wrong.
- echo You manually create a backup of the registry before continuing.
- echo.
- echo Press any key to continue . . .
- pause>nul
- ) else (
- echo The operation completed successfully.
- echo.
- )
- :: ------------------------------------------------------------------------
- :: ------------------------------------------------------------------------
- :: Delete keys in the Registry.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Deleting values in the Registry.
- echo.
- reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /f
- reg delete "HKLM\COMPONENTS\PendingXmlIdentifier" /f
- reg delete "HKLM\COMPONENTS\NextQueueEntryIndex" /f
- reg delete "HKLM\COMPONENTS\AdvancedInstallersNeedResolving" /f
- :: ------------------------------------------------------------------------
- :: ------------------------------------------------------------------------
- :: Add keys in the Registry.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Adding values in the Registry.
- echo.
- reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v AppData /t REG_EXPAND_SZ /d "%USERPROFILE%\AppData\Roaming" /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v AppData /t REG_EXPAND_SZ /d "%USERPROFILE%\AppData\Roaming" /f
- reg add "HKU\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v AppData /t REG_EXPAND_SZ /d "%USERPROFILE%\AppData\Roaming" /f
- reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v AllowOSUpgrade /t REG_DWORD /d 1 /f
- reg add "HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToBackup" /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\microsoft.com\update" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\microsoft.com\update" /v https /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\microsoft.com\windowsupdate" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\update.microsoft.com" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\update.microsoft.com" /v https /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\windowsupdate.com" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\windowsupdate.microsoft.com" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\download.microsoft.com" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\windowsupdate.com" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\windowsupdate.com" /v https /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\windowsupdate.com\download" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\windowsupdate.com\download" /v https /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\download.windowsupdate.com" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\download.windowsupdate.com" /v https /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\windows.com\wustat" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\wustat.windows.com" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\microsoft.com\ntservicepack" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\ntservicepack.microsoft.com" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\microsoft.com\ws" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\microsoft.com\ws" /v https /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\ws.microsoft.com" /v http /t REG_DWORD /d 2 /f
- reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\ws.microsoft.com" /v https /t REG_DWORD /d 2 /f
- :: ------------------------------------------------------------------------
- :: ------------------------------------------------------------------------
- :: End process.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo The operation completed successfully.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Menu
- :: ------------------------------------------------------------------------
- :: /*************************************************************************************/
- :: Run the reset Windows Update components.
- :: /*************************************************************************************/
- :Reset
- :: ------------------------------------------------------------------------
- :: Stopping the Windows Update services.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Stopping the Windows Update services.
- echo.
- net stop bits
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Stopping the Windows Update services.
- echo.
- net stop wuauserv
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Stopping the Windows Update services.
- echo.
- net stop appidsvc
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Stopping the Windows Update services.
- echo.
- net stop cryptsvc
- :: ------------------------------------------------------------------------
- :: ------------------------------------------------------------------------
- :: Checking the services status.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Checking the services status.
- echo.
- sc query bits | findstr /I /C:"STOPPED"
- If not %errorlevel%==0 (
- echo Failed to stop the BITS service.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Close
- )
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Checking the services status.
- echo.
- sc query wuauserv | findstr /I /C:"STOPPED"
- if not %errorlevel%==0 (
- echo Failed to stop the Windows Update service.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Close
- )
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Checking the services status.
- echo.
- sc query appidsvc | findstr /I /C:"STOPPED"
- if not %errorlevel%==0 (
- sc query appidsvc | findstr /I /C:"OpenService FAILED 1060"
- if not %errorlevel%==0 (
- echo Failed to stop the Application Identity service.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Close
- )
- )
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Checking the services status.
- echo.
- sc query cryptsvc | findstr /I /C:"STOPPED"
- If not %errorlevel%==0 (
- echo Failed to stop the Cryptographic Services service.
- echo.
- echo Press any key to continue . . .
- pause>nul
- goto Close
- )
- :: ------------------------------------------------------------------------
- :: ------------------------------------------------------------------------
- :: Delete the qmgr*.dat files.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Deleting the qmgr*.dat files.
- echo.
- del /s /q /f "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr*.dat"
- :: ------------------------------------------------------------------------
- :: ------------------------------------------------------------------------
- :: Renaming the softare distribution folders backup copies.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Renaming the softare distribution folders backup copies.
- echo.
- cd /d %SYSTEMROOT%
- if exist "%SYSTEMROOT%\winsxs\pending.xml" takeown /f "%SYSTEMROOT%\winsxs\pending.xml"
- if exist "%SYSTEMROOT%\winsxs\pending.xml" attrib -r -s -h "%SYSTEMROOT%\winsxs\pending.xml"
- if exist "%SYSTEMROOT%\winsxs\pending.xml.bak" del /s /q /f "%SYSTEMROOT%\winsxs\pending.xml.bak"
- if exist "%SYSTEMROOT%\winsxs\pending.xml" ren "%SYSTEMROOT%\winsxs\pending.xml" pending.xml.bak
- if exist "%SYSTEMROOT%\SoftwareDistribution" attrib -r -s -h "%SYSTEMROOT%\SoftwareDistribution"
- if exist "%SYSTEMROOT%\SoftwareDistribution.bak" rmdir /s /q "%SYSTEMROOT%\SoftwareDistribution.bak"
- if exist "%SYSTEMROOT%\SoftwareDistribution" ren "%SYSTEMROOT%\SoftwareDistribution" SoftwareDistribution.bak
- if exist "%SYSTEMROOT%\system32\Catroot2" attrib -r -s -h "%SYSTEMROOT%\system32\Catroot2"
- if exist "%SYSTEMROOT%\system32\Catroot2.bak" rmdir /s /q "%SYSTEMROOT%\system32\Catroot2.bak"
- if exist "%SYSTEMROOT%\system32\Catroot2" ren "%SYSTEMROOT%\system32\Catroot2" Catroot2.bak
- if exist "%SYSTEMROOT%\WindowsUpdate.log" attrib -r -s -h "%SYSTEMROOT%\WindowsUpdate.log"
- if exist "%SYSTEMROOT%\WindowsUpdate.log.bak" del /s /q /f "%SYSTEMROOT%\WindowsUpdate.log.bak"
- if exist "%SYSTEMROOT%\WindowsUpdate.log" ren "%SYSTEMROOT%\WindowsUpdate.log" WindowsUpdate.log.bak
- :: ------------------------------------------------------------------------
- :: ------------------------------------------------------------------------
- :: Reset the BITS service and the Windows Update service to the default security descriptor.
- cls
- echo.
- echo Microsoft %name% [Versi?n: %version%]
- echo Reset Windows Update Components Tool.
- echo.
- echo Reset the BITS service and the Windows Update service to the default security descriptor.
- echo.
- sc.exe sdset bits D:(A
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement