LINUX.ORG.RU

История изменений

Исправление uwuwuu, (текущая версия) :

На WPower Shell тож скрипт написал, чтобы после обновления когда винда заменяет bootmgfw, двумя кликами фиксить все

# BEGIN RUN SCRIPT AS ADMINISTRATOR
# https://superuser.com/a/532109
param([switch]$elevated)

function Test-Admin {
  $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
  $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

if ((Test-Admin) -eq $false)  {
  if ($elevated) {
    # tried to elevate, did not work, aborting
  } else {
    Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
  }
  exit
}
# END RUN SCRIPT AS ADMINISTRATOR

function Replace-Windows-Boot-Manager {
  param([string]$letter)
  $source = "${letter}:\efi\boot\bootx64.efi"
  $target = "${letter}:\efi\microsoft\boot\bootmgfw.efi"

  if ((Get-FileHash $source).Hash -eq (Get-FileHash $target).Hash) {
    Write-Output "Boot loaders are same!"
    return 0
  }

  # Save original windows boot manager as _bootmgfw.efi
  Move-Item -Path $target -Destination ($target -replace '[^\\]+$', '_$&') -Force

  # Change windows boot manager
  Copy-Item $source $target

  Write-Output "Windows Boot Manager replaced!"
  return 1
}

# Change ESP letter if necessary
Replace-Windows-Boot-Manager -letter "Z"

Исходная версия uwuwuu, :

На WPower Shell тож скрипт написал, чтобы после обновления когда винда заменяет bootmgfw, двумя кликами фиксить все

# BEGIN RUN SCRIPT AS ADMINISTRATOR
# https://superuser.com/a/532109
param([switch]$elevated)

function Test-Admin {
  $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
  $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

if ((Test-Admin) -eq $false)  {
  if ($elevated) {
    # tried to elevate, did not work, aborting
  } else {
    Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
  }
  exit
}
# END RUN SCRIPT AS ADMINISTRATOR

function Replace-Windows-Boot-Manager {
  param([string]$letter)
  $source = "${letter}:\efi\boot\bootx64.efi"
  $target = "${letter}:\efi\microsoft\boot\bootmgfw.efi"

  if ((Get-FileHash $source).Hash -eq (Get-FileHash $target).Hash) {
    Write-Output "Boot loaders are same!"
    return 0
  }

  # Save original windows boot manager as _bootmgfw.efi
  Move-Item -Path $target -Destination ($target -replace '[^\\]+$', '_$&') -Force

  # Change windows boot manager
  Copy-Item $source $target

  Write-Output "Windows Boot Manager replaced!"
  return 1
}

bcdedit /set "{bootmgr}" path "\efi\boot\bootx64.efi"

# Change ESP letter if necessary
Replace-Windows-Boot-Manager -letter "Z"