Tìm kiếm ↓↓↓

Hướng dẫn tạo batch file sử dụng reset windows update trong Windows 10

Nếu máy tính của bạn đang cài đặt Windows 10 gặp phải tình trạng không thể tải và cài đặt được các bản cập nhật hàng tháng từ Microsoft. Lỗi này rất phức tạp và rất nhiều nguyên nhân nếu phải tìm và khắc phục thủ công rất khó và mất thời gian đôi khi lại không khắc phục được. Giải pháp nhanh tróng là sử dụng tập tin batch được tổng hợp các lệnh sửa lỗi liên quan đến Windows Update giúp cho việc khắc phục được nhanh và xử lý tốt hơn.

Hình minh họa khi chạy tập tin batch reset Windows Update trong Windows 10


Cách tạo batch file như sau:

Bước 1: Mở trình soạn thảo notepad copy nội dung bên dưới vào:

@echo off

title Reset Windows Update in Windows 10

>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

if "%errorlevel%" NEQ "0" (

 echo: Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"

 echo: UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

 "%temp%\getadmin.vbs" & exit

)

if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"

set /p="Press any key to reset windows update . . . "<nul

pause >nul

cls

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 Please run the script as administartor by right clicking the WuReset file or your BITS service isn't responding.

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%\Microsoft\Network\Downloader\qmgr*.dat"

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 winsock reset proxy



:Start

net start bits

net start wuauserv

net start appidsvc

net start cryptsvc

echo Task completed sucessfully!

echo Please restart your computer and check for the updates again.

choice /c YN /n /m "Do you want to restart the computer now? (Yes/No) "

if %errorlevel% EQU 0 goto Reboot

if %errorlevel% EQU 1 go to Exit



:Exit

exit



:Reboot

shutdown /r /f /t 00

Bước 2: Lưu lại với tên ví dụ resetupdateinwin10.cmd hoặc resetupdateinwin10.batch, trong khung Save as ( lưu dưới dạng) để All files và khung Encoding (mã hóa) để định dạng ANSI

Nếu bạn thấy phức tạp có thể tải tập tin batch do mình tạo sẵn tại đây về giải nén chạy tập tin reset update.cmd

Lưu ý:
Tập tin batch reset Windows Update yêu cầu khởi động lại máy tính trước khi chạy lại Windows Update, nhấn phím Y xác nhận, sau khi khởi động lại truy cập đường dẫn C:\Windows tìm và xóa thư mục SoftwareDistribution.bak đi.

Phổ biến trong tuần

Tin Tức