Windows 10 Unable to install a patch on windows 10 1607

  • Thread starter Thread starter GuogangFan
  • Start date Start date
G

GuogangFan

I am trying to write a batch script to help users in our company to upgrade their computers to support edge browser and it's IE mode.


@echo off

color
1a

setlocal enableextensions enabledelayedexpansion


set LOGFILE=c:\edgesetup.log

set CDN=http://172.31.25.14/soft

set TRACKER=http://172.31.202.197:5000


rem ni da ye hai shi ni da ye

echo ==========================================================

echo 统一浏览器配置脚本 Win 10 x64 C@V2VZDEZH

echo ==========================================================

echo=


fltmc >>%LOGFILE% 2>&1 || (

echo %date% %time% [E]: Elevated Privilege Needed! >>%LOGFILE% 2>&1

echo 需要以管理员权限运行,5秒后自动退出

timeout 5

exit

)


for /F "tokens=* USEBACKQ" %%F in (`ver`) do (

set VER=%%F

)


if "%PROCESSOR_ARCHITECTURE%"=="x86" (

echo %date% %time% [E]: CPU Architecture Not Supported! >>%LOGFILE% 2>&1

echo 不支持32位的Windows 10操作系统,5秒后自动退出

timeout 5

exit

) else (

set ARCH=x64

)


for /f "tokens=4-8 delims=[.] " %%i in ('ver') do @(if %%i==Version (set verstr=%%j.%%k.%%l.%%m) else (set verstr=%%i.%%j.%%k.%%l))


for /f "tokens=1-5 delims=." %%i in ('echo %verstr%') do @(

set OSV=%%i.%%j

set BLD=%%k

set MIV=%%l

)


if not defined MIV set MIV=0

echo %date% %time% [D] %OSV% %BLD% %MIV% >>%LOGFILE% 2>&1


if not %OSV% == 10.0 (

echo %date% %time% [E] not Windows 10! >>%LOGFILE% 2>&1

echo 非Windows 10操作系统,5秒后自动退出

timeout 5

exit

)


set tempdir=edgesetup

mkdir C:\%tempdir%


rem 1909

if %BLD% equ 18363 goto OA

rem 1903

if %BLD% equ 18362 (if %MIV% lss 207 (set KB=4501375) else (goto OA))

rem 1809

if %BLD% equ 17763 (if %MIV% lss 592 (set KB=4501371) else (goto OA))

rem 1803

if %BLD% equ 17134 (if %MIV% lss 984 (set KB=4512509) else (goto OA))

rem 1709

if %BLD% equ 16299 (if %MIV% lss 1365 (set KB=4512494) else (goto OA))

rem 1703

if %BLD% equ 15063 (if %MIV% lss 2108 (set KB=4520010) else (goto OA))

rem 1607

if %BLD% equ 14393 (if %MIV% lss 3242 (set KB=4516061) else (goto OA))

rem 1511 not supported, not LTSC

rem 1507 not supported, too old to catch up.


if defined KB (

goto patch

) else (

echo %date% %time% [E] unsupported Windows 10 Version %OSV%.%BLD%.%MIV% >>%LOGFILE% 2>&1

echo 不支持的Windows 10操作系统版本%OSV%.%BLD%.%MIV%,5秒后自动退出

timeout 5

exit

)


:patch


powershell
-c "(new-object System.Net.WebClient).DownloadString('%TRACKER%/g?oldV=%verstr%')" >C:\%tempdir%\secret.txt

powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/aria2c.exe','C:\%tempdir%\aria2c.exe')" >>%LOGFILE% 2>&1

powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/win10/win10-%BLD%.torrent','C:\%tempdir%\win10-%BLD%.torrent')" >>%LOGFILE% 2>&1


start /b "" cmd /c C:\%tempdir%\aria2c.exe -T C:\%tempdir%\win10-%BLD%.torrent -d C:\%tempdir% ^>c:\bt.log 2^>^&1


rem P2P download

echo=

echo -------------- 第一步:下载所需的补丁 --------------

echo %date% %time% -------------- Downloading files... --------------- >>%LOGFILE% 2>&1

:waitdownload

timeout
/t 10 /nobreak > NUL

type
c:\bt.log | findstr "SEED(0.0)" >nul 2>&1

if %ErrorLevel% neq 0 goto waitdownload

echo 下载完成。

echo=


rem if BT download is not allowed, use this, but be careful with bandwith usage, better use multiple CDN servers.

rem powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/win10/windows%OSV%-kb%KB%-%ARCH%.msu','C:\%tempdir%\win10-%BLD%\windows%OSV%-kb%KB%-%ARCH%.msu')" >>%LOGFILE% 2>&1

rem if %KB% == 4516061 powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/win10/windows%OSV%-kb4512574-%ARCH%.msu','C:\%tempdir%\win10-%BLD%\windows%OSV%-kb4512574-%ARCH%.msu')" >>%LOGFILE% 2>&1

rem powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/EcologyPlugin.zip','C:\%tempdir%\win10-%BLD%\EcologyPlugin.zip')" >>%LOGFILE% 2>&1

rem powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/MicrosoftEdgeEnterprise%ARCH%.msi','C:\%tempdir%\win10-%BLD%\MicrosoftEdgeEnterprise%ARCH%.msi')" >>%LOGFILE% 2>&1

rem powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/LGPO.exe','C:\%tempdir%\win10-%BLD%\LGPO.exe')" >>%LOGFILE% 2>&1

rem powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/gp.txt','C:\%tempdir%\win10-%BLD%\gp.txt')" >>%LOGFILE% 2>&1

rem powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/isz1.reg','C:\%tempdir%\win10-%BLD%\isz1.reg')" >>%LOGFILE% 2>&1


echo -------------- 第二步:安装所需的补丁 --------------

if %KB% == 4516061 (

echo %date% %time% -------------- Installing dependent patch KB4512574... --------------- >>%LOGFILE% 2>&1

mkdir C:\%tempdir%\4512574

expand -F:* C:\%tempdir%\win10-%BLD%\windows%OSV%-kb4512574-x64.msu C:\%tempdir%\4512574 >>%LOGFILE% 2>&1

for %%i in (C:\%tempdir%\4512574\Windows%OSV%-KB4512574-x64*.cab) do (

echo %date% %time% processing %%i >>%LOGFILE% 2>&1

DISM.exe /Online /Add-Package /PackagePath:%%i /NoRestart >>%LOGFILE% 2>&1

systeminfo | findstr "KB4512574" >>%LOGFILE% 2>&1

set IR=!ErrorLevel!

echo install process return code is !IR! >>%LOGFILE% 2>&1

if !IR! == 0 echo %date% %time% KB4512574 installed successfully >>%LOGFILE% 2>&1

if !IR! == 0 echo 补丁KB4512574安装成功

echo=

)

)


echo %date% %time% -------------- Installing patch KB%KB%... --------------- >>%LOGFILE% 2>&1

mkdir C:\%tempdir%\%KB%

rem

expand -F:* C:\%tempdir%\win10-%BLD%\windows%OSV%-kb%KB%-x64.msu C:\%tempdir%\%KB% >>%LOGFILE% 2>&1

for %%i in (C:\%tempdir%\%KB%\Windows%OSV%-KB%KB%-x64*.cab) do (

echo %%i >>%LOGFILE% 2>&1

DISM.exe /Online /Add-Package /PackagePath:%%i /NoRestart >>%LOGFILE% 2>&1

systeminfo | findstr "%KB%" >>%LOGFILE% 2>&1

set IR=!ErrorLevel!

echo !IR! >>%LOGFILE% 2>&1

if !IR! == 0 (echo 补丁KB%KB%安装成功) else (echo 补丁KB4512574安装失败)

)


:OA


echo
-------------- 第三步:安装设置浏览器 --------------

echo %date% %time% -------------- Installing OA ActiveX control... --------------- >>%LOGFILE% 2>&1


md C:\%tempdir%\EcologyPlugin

powershell -command "Expand-Archive C:\%tempdir%\win10-%BLD%\EcologyPlugin.zip C:\%tempdir%" >>%LOGFILE% 2>&1

call C:\%tempdir%\EcologyPlugin\setup.bat >>%LOGFILE% 2>&1

if %ErrorLevel% == 0 (

echo OA控件安装成功

) else (

echo OA空间安装出错

)


echo %date% %time% -------------- Installing Edge Browser... --------------- >>%LOGFILE% 2>&1

rem allow side by side(old edge with new edge)

reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\EdgeUpdate /v Allowsxs /t REG_DWORD /d 1 /f >>%LOGFILE% 2>&1

rem install without desktop shortcut

reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\EdgeUpdate /v CreateDesktopShortcutDefault /t REG_DWORD /d 0 /f >>%LOGFILE% 2>&1


C:\%tempdir%\win10-%BLD%\MicrosoftEdgeEnterprise%ARCH%.msi /quiet >>%LOGFILE% 2>&1

if %ErrorLevel% == 0 (

echo 新版Edge浏览器安装成功

) else (

echo 新版Edge浏览器安装出错

)


echo %date% %time% -------------- Applying Group Policy... --------------- >>%LOGFILE% 2>&1


C:\%tempdir%\win10-%BLD%\LGPO.exe /t C:\%tempdir%\win10-%BLD%\gp.txt >>%LOGFILE% 2>&1

if %ErrorLevel% == 0 (

echo 组策略设置成功

) else (

echo 组策略设置失败

)


rem see https://support.microsoft.com/en-sg...ity-zones-registry-entries-for-advanced-users

echo %date% %time% -------------- Update Internet Settings... --------------- >>%LOGFILE% 2>&1

reg import C:\%tempdir%\win10-%BLD%\isz1.reg >>%LOGFILE% 2>&1

if %ErrorLevel% == 0 (

echo Internet选项设置成功

) else (

echo Internet选项设置失败

)


rem hide first run see Microsoft Edge Browser Policy Documentation

reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge -v HideFirstRunExperience /t REG_DWORD -d 1 /f >>%LOGFILE% 2>&1

set /p secret= <C:\%tempdir%\secret.txt

rem open verify page at next boot, note here we must use HKCU other than HKLM

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v TestEdgeSetup /d "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe %TRACKER%/v?secret=%secret%&newV=%verstr%" /f >>%LOGFILE% 2>&1

reg query HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v TestEdgeSetup >>%LOGFILE% 2>&1

rem set new Edge as default browser

powershell -c "(new-object System.Net.WebClient).DownloadFile('%CDN%/SetDefaultBrowser.exe','C:\%tempdir%\SetDefaultBrowser.exe')" >>%LOGFILE% 2>&1

C:\%tempdir%\SetDefaultBrowser.exe HKLM "Microsoft Edge"


rem clear

reg add HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v ClearEdgeSetup /d "cmd /C \"rd /Q /S C:\%tempdir%\"" /f >>%LOGFILE% 2>&1


rem if run sliently in background, there is no need to reboot, as we can keep seeding.

rem shutdown /r /t 300



according to this page version 1607 need at least KB4516061 installed. my batch script can install this patch with dism.exe, but windows will rollback it when applying update progress about to finish.


found something in the cbs log :

2020-09-02 11:24:50, Info CSI 00000ebc Loading installer DLL from explicit path: C:\Windows\WinSxS\amd64_microsoft-windows-s..ingstack-base-extra_31bf3856ad364e35_10.0.14393.3200_none_94b6fb091defb387\SupplementalServicingAI.dll 2020-09-02 11:24:50, Info CSI 00000ebd Performing 1 operations as follows: (0) LockComponentPath: flags: 0 comp: {l:16 b:1dd3109ed880d601d707000004058805} pathid: {l:16 b:1dd3109ed880d601d807000004058805} path: [l:120]'\SystemRoot\WinSxS\amd64_microsoft-client-li..pplementalservicing_31bf3856ad364e35_10.0.14393.3241_none_83ba3f31319948d2' pid: 504 starttime: 132434905070083922 2020-09-02 11:24:50, Info CSI 00000ebe Windows::WCP::SupplementalServicingAI::SupplementalServicing::Install. 2020-09-02 11:24:50, Info CSI 00000ebf Windows::WCP::SupplementalServicingAI::SupplementalServicing::Install Phase = 38 2020-09-02 11:24:50, Info CSI 00000ec0 Windows::WCP::SupplementalServicingAI::SupplementalServicing::IsAllowedSKU Checking if it's Allowed SKU 48. 2020-09-02 11:24:50, Info CSI 00000ec1 Windows::WCP::SupplementalServicingAI::SupplementalServicing::Install : SupplementalServicingFlag = 5. 2020-09-02 11:24:50, Info CSI 00000ec2 Windows::WCP::SupplementalServicingAI::SupplementalServicing::Install This machine is not eligible for supplemental servicing 2020-09-02 11:24:50, Info CSI 00000ec3 Performing 1 operations as follows: (0) LockComponentPath: flags: 0 comp: {l:16 b:1dd3109ed880d601d907000004058805} pathid: {l:16 b:1dd3109ed880d601da07000004058805} path: [l:115]'\SystemRoot\WinSxS\x86_microsoft.windows.s..ation.badcomponents_31bf3856ad364e35_10.0.14393.0_none_09e78f632173f4c5' pid: 504 starttime: 132434905070083922 2020-09-02 11:24:50, Error [0x018066] CSI 00000ec4 (F) Failed execution of queue item Installer: Supplemental Servicing AI installer ({4e9a75dd-0792-460c-a238-3f4130c39369}) with HRESULT HRESULT_FROM_WIN32(50). Failure will not be ignored: A rollback will be initiated after all the operations in the installer queue are completed; installer is reliable[gle=0x80004005] 2020-09-02 11:24:50, Info CBS Added C:\Windows\Logs\CBS\CBS.log to WER report. 2020-09-02 11:24:50, Info CBS Could not get active session for current session file logging [HRESULT = 0x80004003 - E_POINTER] 2020-09-02 11:24:50, Info CBS Not able to add pending.xml.bad to Windows Error Report. [HRESULT = 0x80070002 - ERROR_FILE_NOT_FOUND] 2020-09-02 11:24:51, Info CBS Startup: Changing logon timeout to a static timeout: 10800000 2020-09-02 11:24:51, Info CBS Progress: UI message updated. Operation type: Update. Stage: 1 out of 1. Percent progress: 97. 2020-09-02 11:25:06, Info CSI 00000ec5 Creating NT transaction (seq 2), objectname '(null)' 2020-09-02 11:25:06, Info CSI 00000ec6 Created NT transaction (seq 2) result 0x00000000, handle @0x3d8 2020-09-02 11:25:06, Info CSI 00000ec7@2020/9/2:03:25:06.185 Beginning NT transaction commit... 2020-09-02 11:25:06, Info CSI 00000ec8@2020/9/2:03:25:06.201 CSI perf trace: CSIPERF:TXCOMMIT;18518 2020-09-02 11:25:06, Info CSI 00000ec9@2020/9/2:03:25:06.201 CSI Advanced installer perf trace: CSIPERF:AIDONE;{4e9a75dd-0792-460c-a238-3f4130c39369};Microsoft-Client-Licensing-SupplementalServicing, version 10.0.14393.3241, arch amd64, nonSxS, pkt {l:8 b:31bf3856ad364e35};17354841us 2020-09-02 11:25:06, Info CSI 00000eca End executing advanced installer (sequence 2490) Completion status: HRESULT_FROM_WIN32(ERROR_ADVANCED_INSTALLER_FAILED)





please help!

Continue reading...
 
Back
Top