Skip to content

Instantly share code, notes, and snippets.

@suuhm
Last active June 6, 2024 13:32
Show Gist options
  • Save suuhm/19a1758caf21a14c4a72770d0c6cecf0 to your computer and use it in GitHub Desktop.
Save suuhm/19a1758caf21a14c4a72770d0c6cecf0 to your computer and use it in GitHub Desktop.
Windows Update fails with error code 0x80073701 fix - win 10 window server 2016-2019 etc.
@echo off
echo Get CBS.logs (sfc /scannow)
echo\
set "logPath=C:\Windows\Logs\CBS\CBS.log"
set "searchString=Failed to pin deployment while resolving Update"
for /f "tokens=*" %%a in ('findstr /c:"%searchString%" "%logPath%"') do (
set "errorLine=%%a"
)
if not defined errorLine (
echo Failed to find string.
) else (
echo Get KBfile: %errorLine%
for /f "tokens=*" %%b in ("%errorLine%") do (
set "kbNumber=%%b"
)
echo Get KBfile Update: %kbNumber%
)
echo\
echo Download KBfiles from windows update catalog
echo\
set "DOWNLOAD_DIR=C:\temp\"
set "url=https://URL.com\windows10.0-kb123456-x64_961e82abaca6fa50073f65c96143730824956f7d.msu"
set "output=C:\temp\windows10.0-kb123456-x64_961e82abaca6fa50073f65c96143730824956f7d.msu"
bitsadmin /transfer myDownloadJob /download /priority normal %url% %output%
cd %DOWNLOAD_DIR%
echo\
echo Expand the msu file...
expand .\windows10.0-kb123456-x64_961e82abaca6fa50073f65c96143730824956f7d.msu -f:* .
REM replace with thze right KBfile!
dism.exe /Online /Add-Package /PackagePath:.\Windows10.0-KB123456-x64.cab
echo\
echo restart now
pause
shutdown /r /t0
REM pause>nul
@echo off
REM WINDOWS SRVER FIX 0x80073701
REM (c) 2023 by suuhm
net stop wuauserv
net stop cryptsvc
net stop bits
net stop msiserver
ren C:\Windows\SoftwareDistribution SoftwareDistribution.old
ren C:\Windows\System32\catroot2 catroot2.old
net start wuauserv
net start cryptsvc
net start bits
net start msiserver
shutdown /r /t 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment