Ghost32 - 安全的系统软件下载站!

ghost32怎么安装系统|装机必备|最新专题|最近更新

当前位置:首页 > 系统文章 > win11教程

修复 Windows 中使用 KB5034957 PowerShell 脚本KB5034441错误0x80070643

时间:2024-01-19 10:57:11 来源: 点击:
手机扫码继续观看
修复 Windows 中使用 KB5034957 PowerShell 脚本KB5034441错误0x80070643

  修复 Windows 中使用 KB5034957 PowerShell 脚本KB5034441错误0x80070643

  发布KB5034441是为了处理一个安全漏洞,该漏洞可能允许攻击者使用 WinRE 规避 BitLocker 加密,但这对用户来说是一场灾难。他们开始在不同的技术论坛上抱怨错误0x80070643阻止在设备上安装更新。但是,我们在 – 修复 Windows 10 22H2、21H2 中无法安装错误0x80070643 KB5034441 中介绍了一篇文章来挽救这个问题。现在,Microsoft通过 KB5034957 推出了示例 PowerShell 脚本更新,以自动执行安装并绕过错误。

  安装KB5034441时,由于系统预留分区大小小于 250 MB 的可用空间,因此出现错误0x80070643。此错误代码是指ERROR_INSTALL_FAILURE,要处理该问题,您需要手动调整恢复分区的大小。为了解决此问题,KB5034957运行时,它将通过 PowerShell 脚本自动调整系统保留分区的大小。由于这是官方发布,因此无需担心其他问题和影响。

  KB5034957 PowerShell 脚本修复KB5034441错误0x80070643

  以下是在 Windows 中使用 KB5034957 PowerShell 脚本修复KB5034441错误0x80070643的方法:

  运行 PowerShell 脚本

  KB5034441提供了 2 个 PowerShell 脚本,您需要在相应的版本上手动运行它们。他们将更新 WINRE 并使 Windows 11 和 10 能够安装KB5034441而不会出现任何错误。

  此外,此脚本将装载现有的 WinRE 映像 (WINRE.WIM)使用指定的安全 OS 动态更新对 WinRE 映像进行更新,然后卸载 WinRE 映像。 如果 BitLocker TPM 保护程序可用,KB5034441将为 BitLocker 服务重新配置 WinRE。

  让我们先看看 Microsoft 对这些脚本的声明:

  示例 PowerShell 脚本

  示例 PowerShell 脚本由 Microsoft 产品团队开发,可帮助在受支持的 Windows 10 和 Windows 11 设备上自动更新 WinRE 映像。在受影响的设备上,使用管理员凭据在 PowerShell 中运行脚本。有两个脚本可用 - 应使用哪个脚本取决于您运行的 Windows 版本。请使用适合您环境的版本。

  现在,运行脚本:

  1、 PatchWinREScript_2004plus.ps1 (推荐)

  此脚本适用于 Windows 10 版本 2004 及更高版本,包括 Windows 11。建议使用此版本的脚本,因为它更可靠,但使用仅在 Windows 10 版本 2004 及更高版本上可用的功能。

  请按照以下步骤操作:

  1. 确保安装了最新版本的 SafeOS 动态更新。(KB5034234 Windows 11、23H2 和 22H2 的动态更新)

  2. 复制以下脚本:

  #

  # Copyright (c) Microsoft Corporation.

  # Licensed under the MIT License.

  #

  # THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

  # SOFTWARE.

  #

  ################################################################################################

  Param (

  [Parameter(HelpMessage="Work Directory for patch WinRE")][string]$workDir="",

  [Parameter(Mandatory=$true,HelpMessage="Path of target package")][string]$packagePath

  )

  # ------------------------------------

  # Help functions

  # ------------------------------------

  # Log message

  function LogMessage([string]$message)

  {

  $message = "$([DateTime]::Now) - $message"

  Write-Host $message

  }

  function IsTPMBasedProtector

  {

  $DriveLetter = $env:SystemDrive

  LogMessage("Checking BitLocker status")

  $BitLocker = Get-WmiObject -Namespace "Root\cimv2\Security\MicrosoftVolumeEncryption" -Class "Win32_EncryptableVolume" -Filter "DriveLetter = '$DriveLetter'"

  if(-not $BitLocker)

  {

  LogMessage("No BitLocker object")

  return $False

  }

  $protectionEnabled = $False

  switch ($BitLocker.GetProtectionStatus().protectionStatus){

  ("0"){

  LogMessage("Unprotected")

  break

  }

  ("1"){

  LogMessage("Protected")

  $protectionEnabled = $True

  break

  }

  ("2"){

  LogMessage("Uknown")

  break

  }

  default{

  LogMessage("NoReturn")

  break

  }

  }

  if (!$protectionEnabled)

  {

  LogMessage("Bitlocker isn’t enabled on the OS")

  return $False

  }

  $ProtectorIds = $BitLocker.GetKeyProtectors("0").volumekeyprotectorID

  $return = $False

  foreach ($ProtectorID in $ProtectorIds){

  $KeyProtectorType = $BitLocker.GetKeyProtectorType($ProtectorID).KeyProtectorType

  switch($KeyProtectorType){

  "1"{

  LogMessage("Trusted Platform Module (TPM)")

  $return = $True

  break

  }

  "4"{

  LogMessage("TPM And PIN")

  $return = $True

  break

  }

  "5"{

  LogMessage("TPM And Startup Key")

  $return = $True

  break

  }

  "6"{

  LogMessage("TPM And PIN And Startup Key")

  $return = $True

  break

  }

  default {break}

  }#endSwitch

  }#EndForeach

  if ($return)

  {

  LogMessage("Has TPM-based protector")

  }

  else

  {

  LogMessage("Doesn't have TPM-based protector")

  }

  return $return

  }

  function SetRegistrykeyForSuccess

  {

  reg add HKLM\SOFTWARE\Microsoft\PushButtonReset /v WinREPathScriptSucceed /d 1 /f

  }

  function TargetfileVersionExam([string]$mountDir)

  {

  # Exam target binary

  $targetBinary=$mountDir + "\Windows\System32\bootmenuux.dll"

  LogMessage("TargetFile: " + $targetBinary)

  $realNTVersion = [Diagnostics.FileVersionInfo]::GetVersionInfo($targetBinary).ProductVersion

  $versionString = "$($realNTVersion.Split('.')[0]).$($realNTVersion.Split('.')[1])"

  $fileVersion = $($realNTVersion.Split('.')[2])

  $fileRevision = $($realNTVersion.Split('.')[3])

  LogMessage("Target file version: " + $realNTVersion)

  if (!($versionString -eq "10.0"))

  {

  LogMessage("Not Windows 10 or later")

  return $False

  }

  $hasUpdated = $False

  #Windows 10, version 1507 10240.19567

  #Windows 10, version 1607 14393.5499

  #Windows 10, version 1809 17763.3646

  #Windows 10, version 2004 1904X.2247

  #Windows 11, version 21H2 22000.1215

  #Windows 11, version 22H2 22621.815

  switch ($fileVersion) {

  "10240" {

  LogMessage("Windows 10, version 1507")

  if ($fileRevision -ge 19567)

  {

  LogMessage("Windows 10, version 1507 with revision " + $fileRevision + " >= 19567, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "14393" {

  LogMessage("Windows 10, version 1607")

  if ($fileRevision -ge 5499)

  {

  LogMessage("Windows 10, version 1607 with revision " + $fileRevision + " >= 5499, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "17763" {

  LogMessage("Windows 10, version 1809")

  if ($fileRevision -ge 3646)

  {

  LogMessage("Windows 10, version 1809 with revision " + $fileRevision + " >= 3646, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "19041" {

  LogMessage("Windows 10, version 2004")

  if ($fileRevision -ge 2247)

  {

  LogMessage("Windows 10, version 2004 with revision " + $fileRevision + " >= 2247, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "22000" {

  LogMessage("Windows 11, version 21H2")

  if ($fileRevision -ge 1215)

  {

  LogMessage("Windows 11, version 21H2 with revision " + $fileRevision + " >= 1215, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "22621" {

  LogMessage("Windows 11, version 22H2")

  if ($fileRevision -ge 815)

  {

  LogMessage("Windows 11, version 22H2 with revision " + $fileRevision + " >= 815, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  default {

  LogMessage("Warning: unsupported OS version")

  }

  }

  return $hasUpdated

  }

  function PatchPackage([string]$mountDir, [string]$packagePath)

  {

  # Exam target binary

  $hasUpdated =TargetfileVersionExam($mountDir)

  if ($hasUpdated)

  {

  LogMessage("The update has already been added to WinRE")

  SetRegistrykeyForSuccess

  return $False

  }

  # Add package

  LogMessage("Apply package:" + $packagePath)

  Dism /Add-Package /Image:$mountDir /PackagePath:$packagePath

  if ($LASTEXITCODE -eq 0)

  {

  LogMessage("Successfully applied the package")

  }

  else

  {

  LogMessage("Applying the package failed with exit code: " + $LASTEXITCODE)

  return $False

  }

  # Cleanup recovery image

  LogMessage("Cleanup image")

  Dism /image:$mountDir /cleanup-image /StartComponentCleanup /ResetBase

  if ($LASTEXITCODE -eq 0)

  {

  LogMessage("Cleanup image succeed")

  }

  else

  {

  LogMessage("Cleanup image failed: " + $LASTEXITCODE)

  return $False

  }

  return $True

  }

  # ------------------------------------

  # Execution starts

  # ------------------------------------

  # Check breadcrumb

  if (Test-Path HKLM:\Software\Microsoft\PushButtonReset)

  {

  $values = Get-ItemProperty -Path HKLM:\Software\Microsoft\PushButtonReset

  if (!(-not $values))

  {

  if (Get-Member -InputObject $values -Name WinREPathScriptSucceed)

  {

  $value = Get-ItemProperty -Path HKLM:\Software\Microsoft\PushButtonReset -Name WinREPathScriptSucceed

  if ($value.WinREPathScriptSucceed -eq 1)

  {

  LogMessage("This script was previously run successfully")

  exit 1

  }

  }

  }

  }

  if ([string]::IsNullorEmpty($workDir))

  {

  LogMessage("No input for mount directory")

  LogMessage("Use default path from temporary directory")

  $workDir = [System.IO.Path]::GetTempPath()

  }

  LogMessage("Working Dir: " + $workDir)

  $name = "CA551926-299B-27A55276EC22_Mount"

  $mountDir = Join-Path $workDir $name

  LogMessage("MountDir: " + $mountdir)

  # Delete existing mount directory

  if (Test-Path $mountDir)

  {

  LogMessage("Mount directory: " + $mountDir + " already exists")

  LogMessage("Try to unmount it")

  Dism /unmount-image /mountDir:$mountDir /discard

  if (!($LASTEXITCODE -eq 0))

  {

  LogMessage("Warning: unmount failed: " + $LASTEXITCODE)

  }

  LogMessage("Delete existing mount direcotry " + $mountDir)

  Remove-Item $mountDir -Recurse

  }

  # Create mount directory

  LogMessage("Create mount directory " + $mountDir)

  New-Item -Path $mountDir -ItemType Directory

  # Set ACL for mount directory

  LogMessage("Set ACL for mount directory")

  icacls $mountDir /inheritance:r

  icacls $mountDir /grant:r SYSTEM:"(OI)(CI)(F)"

  icacls $mountDir /grant:r *S-1-5-32-544:"(OI)(CI)(F)"

  # Mount WinRE

  LogMessage("Mount WinRE:")

  reagentc /mountre /path $mountdir

  if ($LASTEXITCODE -eq 0)

  {

  # Patch WinRE

  if (PatchPackage -mountDir $mountDir -packagePath $packagePath)

  {

  $hasUpdated = TargetfileVersionExam($mountDir)

  if ($hasUpdated)

  {

  LogMessage("After patch, find expected version for target file")

  }

  else

  {

  LogMessage("Warning: After applying the patch, unexpected version found for the target file")

  }

  LogMessage("Patch succeed, unmount to commit change")

  Dism /unmount-image /mountDir:$mountDir /commit

  if (!($LASTEXITCODE -eq 0))

  {

  LogMessage("Unmount failed: " + $LASTEXITCODE)

  exit 1

  }

  else

  {

  if ($hasUpdated)

  {

  if (IsTPMBasedProtector)

  {

  # Disable WinRE and re-enable it to let new WinRE be trusted by BitLocker

  LogMessage("Disable WinRE")

  reagentc /disable

  LogMessage("Re-enable WinRE")

  reagentc /enable

  reagentc /info

  }

  # Leave a breadcrumb indicates the script has succeed

  SetRegistrykeyForSuccess

  }

  }

  }

  else

  {

  LogMessage("Patch failed or is not applicable, discard unmount")

  Dism /unmount-image /mountDir:$mountDir /discard

  if (!($LASTEXITCODE -eq 0))

  {

  LogMessage("Unmount failed: " + $LASTEXITCODE)

  exit 1

  }

  }

  }

  else

  {

  LogMessage("Mount failed: " + $LASTEXITCODE)

  }

  # Cleanup Mount directory in the end

  LogMessage("Delete mount direcotry")

  Remove-Item $mountDir -Recurse

  3. 粘贴到记事本中,并使用名称 PatchWinREScript_General.ps1 保存.

  4. 右键单击此文件,然后选择“使用 PowerShell 运行”.

  2] PatchWinREScript_General.ps1

  此脚本适用于 Windows 10 版本 1909 及更早版本,但在所有版本的 Windows 10 和 Windows 11 上执行。

  请按照以下步骤操作:

  1. 确保在设备上安装了 SafeOS 动态更新,然后打开记事本。

  2. 复制以下脚本,并将其保存为名称 PatchWinREScript_General.ps1.

  ################################################################################################

  #

  # Copyright (c) Microsoft Corporation.

  # Licensed under the MIT License.

  #

  # THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

  # SOFTWARE.

  #

  ################################################################################################

  Param (

  [Parameter(HelpMessage="Work Directory for patch WinRE")][string]$workDir="",

  [Parameter(Mandatory=$true,HelpMessage="Path of target package")][string]$packagePath

  )

  # ------------------------------------

  # Help functions

  # ------------------------------------

  # Log message

  function LogMessage([string]$message)

  {

  $message = "$([DateTime]::Now) - $message"

  Write-Host $message

  }

  function IsTPMBasedProtector

  {

  $DriveLetter = $env:SystemDrive

  LogMessage("Checking BitLocker status")

  $BitLocker = Get-WmiObject -Namespace "Root\cimv2\Security\MicrosoftVolumeEncryption" -Class "Win32_EncryptableVolume" -Filter "DriveLetter = '$DriveLetter'"

  if(-not $BitLocker)

  {

  LogMessage("No BitLocker object")

  return $False

  }

  $protectionEnabled = $False

  switch ($BitLocker.GetProtectionStatus().protectionStatus){

  ("0"){

  LogMessage("Unprotected")

  break

  }

  ("1"){

  LogMessage("Protected")

  $protectionEnabled = $True

  break

  }

  ("2"){

  LogMessage("Uknown")

  break

  }

  default{

  LogMessage("NoReturn")

  break

  }

  }

  if (!$protectionEnabled)

  {

  LogMessage("Bitlocker isn’t enabled on the OS")

  return $False

  }

  $ProtectorIds = $BitLocker.GetKeyProtectors("0").volumekeyprotectorID

  $return = $False

  foreach ($ProtectorID in $ProtectorIds){

  $KeyProtectorType = $BitLocker.GetKeyProtectorType($ProtectorID).KeyProtectorType

  switch($KeyProtectorType){

  "1"{

  LogMessage("Trusted Platform Module (TPM)")

  $return = $True

  break

  }

  "4"{

  LogMessage("TPM And PIN")

  $return = $True

  break

  }

  "5"{

  LogMessage("TPM And Startup Key")

  $return = $True

  break

  }

  "6"{

  LogMessage("TPM And PIN And Startup Key")

  $return = $True

  break

  }

  default {break}

  }#endSwitch

  }#EndForeach

  if ($return)

  {

  LogMessage("Has TPM-based protector")

  }

  else

  {

  LogMessage("Doesn't have TPM-based protector")

  }

  return $return

  }

  function SetRegistrykeyForSuccess

  {

  reg add HKLM\SOFTWARE\Microsoft\PushButtonReset /v WinREPathScriptSucceed /d 1 /f

  }

  function TargetfileVersionExam([string]$mountDir)

  {

  # Exam target binary

  $targetBinary=$mountDir + "\Windows\System32\bootmenuux.dll"

  LogMessage("TargetFile: " + $targetBinary)

  $realNTVersion = [Diagnostics.FileVersionInfo]::GetVersionInfo($targetBinary).ProductVersion

  $versionString = "$($realNTVersion.Split('.')[0]).$($realNTVersion.Split('.')[1])"

  $fileVersion = $($realNTVersion.Split('.')[2])

  $fileRevision = $($realNTVersion.Split('.')[3])

  LogMessage("Target file version: " + $realNTVersion)

  if (!($versionString -eq "10.0"))

  {

  LogMessage("Not Windows 10 or later")

  return $False

  }

  $hasUpdated = $False

  #Windows 10, version 1507 10240.19567

  #Windows 10, version 1607 14393.5499

  #Windows 10, version 1809 17763.3646

  #Windows 10, version 2004 1904X.2247

  #Windows 11, version 21H2 22000.1215

  #Windows 11, version 22H2 22621.815

  switch ($fileVersion) {

  "10240" {

  LogMessage("Windows 10, version 1507")

  if ($fileRevision -ge 19567)

  {

  LogMessage("Windows 10, version 1507 with revision " + $fileRevision + " >= 19567, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "14393" {

  LogMessage("Windows 10, version 1607")

  if ($fileRevision -ge 5499)

  {

  LogMessage("Windows 10, version 1607 with revision " + $fileRevision + " >= 5499, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "17763" {

  LogMessage("Windows 10, version 1809")

  if ($fileRevision -ge 3646)

  {

  LogMessage("Windows 10, version 1809 with revision " + $fileRevision + " >= 3646, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "19041" {

  LogMessage("Windows 10, version 2004")

  if ($fileRevision -ge 2247)

  {

  LogMessage("Windows 10, version 2004 with revision " + $fileRevision + " >= 2247, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "22000" {

  LogMessage("Windows 11, version 21H2")

  if ($fileRevision -ge 1215)

  {

  LogMessage("Windows 11, version 21H2 with revision " + $fileRevision + " >= 1215, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  "22621" {

  LogMessage("Windows 11, version 22H2")

  if ($fileRevision -ge 815)

  {

  LogMessage("Windows 11, version 22H2 with revision " + $fileRevision + " >= 815, updates have been applied")

  $hasUpdated = $True

  }

  break

  }

  default {

  LogMessage("Warning: unsupported OS version")

  }

  }

  return $hasUpdated

  }

  function PatchPackage([string]$mountDir, [string]$packagePath)

  {

  # Exam target binary

  $hasUpdated = TargetfileVersionExam($mountDir)

  if ($hasUpdated)

  {

  LogMessage("The update has already been added to WinRE")

  SetRegistrykeyForSuccess

  return $False

  }

  # Add package

  LogMessage("Apply package:" + $packagePath)

  Dism /Add-Package /Image:$mountDir /PackagePath:$packagePath

  if ($LASTEXITCODE -eq 0)

  {

  LogMessage("Successfully applied the package")

  }

  else

  {

  LogMessage("Applying the package failed with exit code: " + $LASTEXITCODE)

  return $False

  }

  # Cleanup recovery image

  LogMessage("Cleanup image")

  Dism /image:$mountDir /cleanup-image /StartComponentCleanup /ResetBase

  if ($LASTEXITCODE -eq 0)

  {

  LogMessage("Cleanup image succeed")

  }

  else

  {

  LogMessage("Cleanup image failed: " + $LASTEXITCODE)

  return $False

  }

  return $True

  }

  # ------------------------------------

  # Execution starts

  # ------------------------------------

  # Check breadcrumb

  if (Test-Path HKLM:\Software\Microsoft\PushButtonReset)

  {

  $values = Get-ItemProperty -Path HKLM:\Software\Microsoft\PushButtonReset

  if (!(-not $values))

  {

  if (Get-Member -InputObject $values -Name WinREPathScriptSucceed)

  {

  $value = Get-ItemProperty -Path HKLM:\Software\Microsoft\PushButtonReset -Name WinREPathScriptSucceed

  if ($value.WinREPathScriptSucceed -eq 1)

  {

  LogMessage("This script was previously run successfully")

  exit 1

  }

  }

  }

  }

  # Get WinRE info

  $WinREInfo = Reagentc /info

  $findLocation = $False

  foreach ($line in $WinREInfo)

  {

  $params = $line.Split(':')

  if ($params.count -le 1)

  {

  continue

  }

  if ($params[1].Lenght -eq 0)

  {

  continue

  }

  $content = $params[1].Trim()

  if ($content.Lenght -eq 0)

  {

  continue

  }

  $index = $content.IndexOf("\\?\")

  if ($index -ge 0)

  {

  LogMessage("Find \\?\ at " + $index + " for [" + $content + "]")

  $WinRELocation = $content

  $findLocation = $True

  }

  }

  if (!$findLocation)

  {

  LogMessage("WinRE Disabled")

  exit 1

  }

  LogMessage("WinRE Enabled. WinRE location:" + $WinRELocation)

  $WinREFile = $WinRELocation + "\winre.wim"

  if ([string]::IsNullorEmpty($workDir))

  {

  LogMessage("No input for mount directory")

  LogMessage("Use default path from temporary directory")

  $workDir = [System.IO.Path]::GetTempPath()

  }

  LogMessage("Working Dir: " + $workDir)

  $name = "CA551926-299B-27A55276EC22_Mount"

  $mountDir = Join-Path $workDir $name

  LogMessage("MountDir: " + $mountdir)

  # Delete existing mount directory

  if (Test-Path $mountDir)

  {

  LogMessage("Mount directory: " + $mountDir + " already exists")

  LogMessage("Try to unmount it")

  Dism /unmount-image /mountDir:$mountDir /discard

  if (!($LASTEXITCODE -eq 0))

  {

  LogMessage("Warning: unmount failed: " + $LASTEXITCODE)

  }

  LogMessage("Delete existing mount direcotry " + $mountDir)

  Remove-Item $mountDir -Recurse

  }

  # Create mount directory

  LogMessage("Create mount directory " + $mountDir)

  New-Item -Path $mountDir -ItemType Directory

  # Set ACL for mount directory

  LogMessage("Set ACL for mount directory")

  icacls $mountDir /inheritance:r

  icacls $mountDir /grant:r SYSTEM:"(OI)(CI)(F)"

  icacls $mountDir /grant:r *S-1-5-32-544:"(OI)(CI)(F)"

  # Mount WinRE

  LogMessage("Mount WinRE:")

  Dism /mount-image /imagefile:$WinREFile /index:1 /mountdir:$mountDir

  if ($LASTEXITCODE -eq 0)

  {

  # Patch WinRE

  if (PatchPackage -mountDir $mountDir -packagePath $packagePath)

  {

  $hasUpdated = TargetfileVersionExam($mountDir)

  if ($hasUpdated)

  {

  LogMessage("After patch, find expected version for target file")

  }

  else

  {

  LogMessage("Warning: After applying the patch, unexpected version found for the target file")

  }

  LogMessage("Patch succeed, unmount to commit change")

  Dism /unmount-image /mountDir:$mountDir /commit

  if (!($LASTEXITCODE -eq 0))

  {

  LogMessage("Unmount failed: " + $LASTEXITCODE)

  exit 1

  }

  else

  {

  if ($hasUpdated)

  {

  if (IsTPMBasedProtector)

  {

  # Disable WinRE and re-enable it to let new WinRE be trusted by BitLocker

  LogMessage("Disable WinRE")

  reagentc /disable

  LogMessage("Re-enable WinRE")

  reagentc /enable

  reagentc /info

  }

  # Leave a breadcrumb indicates the script has succeed

  SetRegistrykeyForSuccess

  }

  }

  }

  else

  {

  LogMessage("Patch failed or is not applicable, discard unmount")

  Dism /unmount-image /mountDir:$mountDir /discard

  if (!($LASTEXITCODE -eq 0))

  {

  LogMessage("Unmount failed: " + $LASTEXITCODE)

  exit 1

  }

  }

  }

  else

  {

  LogMessage("Mount failed: " + $LASTEXITCODE)

  }

  # Cleanup Mount directory in the end

  LogMessage("Delete mount direcotry")

  Remove-Item $mountDir -Recurse

  3. 右键单击 PatchWinREScript_General.ps1,然后选择“使用 PowerShell 运行”。

上一篇:修复 Windows 中的 AacAmbientLighting.exe 应用程序错误

下一篇:如何在 Windows 11 中使用PowerShell清空回收站

相关文章

网友评论(共有 0 条评论)

请自觉遵守互联网相关政策法规,评论内容只代表网友观点,与本站立场无关!

最新评论