ATUALIZE AGORA OU SE ARREPENDA! Feature Update H1/H2 do Windows 2026

Atualização de Versões do Windows

Atualização de Versões do Windows: Segurança, Estabilidade e Novos Recursos

Manter o Windows atualizado vai muito além de simplesmente instalar correções. As chamadas Feature Updates representam evoluções completas do sistema operacional.

Essas atualizações trazem melhorias de desempenho, novos recursos, ajustes de compatibilidade e, principalmente, reforços críticos de segurança.

Por Que Atualizar as Versões do Windows?

As atualizações de versão (H1 / H2) normalmente incluem:

• Melhorias de desempenho e estabilidade
• Novos recursos e ajustes visuais
• Correções profundas no núcleo do sistema
• Patches de segurança críticos
• Compatibilidade com hardware moderno

Ignorar essas atualizações pode expor o sistema a falhas já corrigidas, vulnerabilidades conhecidas e problemas de compatibilidade.

O Que Este Script Faz?

Este script combina BAT + PowerShell para criar uma ferramenta administrativa de gerenciamento de Feature Updates.

Ele permite:

• Detectar automaticamente o tipo de sistema
• Elevar privilégios para Administrador
• Identificar versão, edição e build
• Comparar versões H1 / H2
• Definir versão-alvo (TargetReleaseVersion)
• Buscar e instalar updates
• Gerar logs detalhados

Script Completo

@echo off
setlocal EnableExtensions EnableDelayedExpansion

REM ============================================================
REM @CANALFORADOAROFICIAL - FEATURE UPDATE (H1/H2) TOOL 2026
REM ONE-FILE: BAT + PowerShell temporario (Win10/Win11 + Servers atuais)
REM ============================================================

REM --- Detecta Server/Workstation (ProductType: 1=Workstation, 2=DC, 3=Server) [web:117]
set "PT="
for /f "skip=1 delims=" %%A in ('wmic os get ProductType 2^>nul') do (
  if not "%%A"=="" (
    for /f "tokens=* delims= " %%B in ("%%A") do set "PT=%%B"
    goto :PT_DONE
  )
)
:PT_DONE
set "MODE=WORKSTATION"
if "%PT%"=="2" set "MODE=SERVER (DC)"
if "%PT%"=="3" set "MODE=SERVER"
title @CANALFORADOAROFICIAL - FEATURE UPDATE 2026 - %MODE%

REM --- UAC Elevation (ShellExecute runas) [web:40]
net session >nul 2>&1
if %errorlevel% neq 0 (
  echo Solicitando privilegios de Administrador...
  cd /d "%~dp0"
  mshta "javascript:var sh=new ActiveXObject('shell.application');sh.ShellExecute('%~nx0','','','runas',1);close();"
  exit /b
)

REM --- Arquivo temporario PS1 (evita Invoke-Expression) [web:133]
set "PS1TMP=%TEMP%\FeatureUpdate_2026_%RANDOM%%RANDOM%.ps1"

call :WRITE_PS "%PS1TMP%"
if not exist "%PS1TMP%" (
  echo ERRO: Nao consegui criar o PS1 temporario.
  pause
  exit /b 2
)

powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File "%PS1TMP%"
set "RC=%ERRORLEVEL%"

del /f /q "%PS1TMP%" >nul 2>&1
exit /b %RC%

:WRITE_PS
set "OUT=%~1"
set "START="
(for /f "usebackq delims=" %%L in ("%~f0") do (
  if defined START (
    echo(%%L
  ) else (
    if "%%L"==":PS_SCRIPT" set "START=1"
  )
)) > "%OUT%"
goto :eof


:PS_SCRIPT
#requires -Version 5.1

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8

$Host.UI.RawUI.BackgroundColor = "DarkMagenta"
$Host.UI.RawUI.ForegroundColor = "White"

$Width = 100
$Height = 30
$Host.UI.RawUI.WindowSize = New-Object System.Management.Automation.Host.Size($Width, $Height)
$Host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size($Width, 3000)

Clear-Host
$Host.UI.RawUI.WindowTitle = "@CANALFORADOAROFICIAL - FEATURE UPDATE TOOL 2026"

try { $ProductType = (Get-CimInstance Win32_OperatingSystem).ProductType } catch { $ProductType = 1 }
$IsServer = ($ProductType -ne 1)

$LogPath = "$env:USERPROFILE\Desktop\FeatureUpdate_Log.txt"
function Write-Log {
  param([Parameter(Mandatory)][string]$Message)
  $Time = Get-Date -Format "dd/MM/yyyy HH:mm:ss"
  Add-Content -Path $LogPath -Value "[$Time] $Message"
}

function Show-Header {
  Clear-Host
  Write-Host "=============================================================" -ForegroundColor White
  Write-Host "   @CANALFORADOAROFICIAL - FEATURE UPDATE (H1/H2) TOOL 2026    " -ForegroundColor Cyan
  Write-Host "=============================================================" -ForegroundColor White
  Write-Host ""
  if ($IsServer) {
    Write-Host "[MODO SERVIDOR] Sem AutoReboot (reinicio manual/confirmado)." -ForegroundColor Yellow
    Write-Host ""
  }
}

function Pause-Script { Write-Host ""; [void](Read-Host "Pressione ENTER para continuar") }

function Confirm-YesNo {
  param([Parameter(Mandatory)][string]$Message)
  $resp = Read-Host "$Message (S/N)"
  return ($resp -match '^(S|s|SIM|sim)$')
}

function Ensure-PSWindowsUpdate {
  if (-not (Get-Module -ListAvailable -Name PSWindowsUpdate)) {
    Show-Header
    Write-Host "[INFO] Instalando PSWindowsUpdate..." -ForegroundColor Yellow
    Write-Log "PSWindowsUpdate nao encontrado -> instalando"
    try {
      Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -ErrorAction SilentlyContinue
      Install-Module PSWindowsUpdate -Force -Scope AllUsers -ErrorAction Stop
      Write-Log "PSWindowsUpdate instalado"
    } catch {
      Write-Host ""
      Write-Host "[ERRO] Falha ao instalar PSWindowsUpdate." -ForegroundColor Yellow
      Write-Host "Possiveis causas: internet, proxy, TLS, PSGallery bloqueada." -ForegroundColor Yellow
      Write-Log ("Falha instalacao PSWindowsUpdate: {0}" -f $_.Exception.Message)
      Pause-Script
      return $false
    }
  }

  try {
    Import-Module PSWindowsUpdate -ErrorAction Stop
    Write-Log "PSWindowsUpdate importado"
    return $true
  } catch {
    Write-Host ""
    Write-Host "[ERRO] Falha ao importar PSWindowsUpdate." -ForegroundColor Yellow
    Write-Log ("Falha import PSWindowsUpdate: {0}" -f $_.Exception.Message)
    Pause-Script
    return $false
  }
}

function Get-DisplayVersion {
  try {
    $cv = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    if ($cv.DisplayVersion) { return [string]$cv.DisplayVersion }
    if ($cv.ReleaseId) { return [string]$cv.ReleaseId }
    return ""
  } catch { return "" }
}

function Get-WinIdentity {
  try {
    $cv = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    [pscustomobject]@{
      ProductName    = [string]$cv.ProductName
      EditionID      = [string]$cv.EditionID
      DisplayVersion = (Get-DisplayVersion)
      CurrentBuild   = [string]$cv.CurrentBuild
      UBR            = [string]$cv.UBR
    }
  } catch {
    [pscustomobject]@{ ProductName="Windows"; EditionID=""; DisplayVersion=""; CurrentBuild=""; UBR="" }
  }
}

function Compare-Hx {
  param([Parameter(Mandatory)][string]$Current,[Parameter(Mandatory)][string]$Target)
  function ToNum([string]$v){
    if ($v -match '^(\d{2})H([12])$') { return ([int]$Matches[1] * 10) + [int]$Matches[2] }
    -1
  }
  $c = ToNum $Current
  $t = ToNum $Target
  if ($c -lt 0 -or $t -lt 0) { return "N/A" }
  if ($c -lt $t) { return "MENOR" }
  if ($c -gt $t) { return "MAIOR" }
  "IGUAL"
}

function Get-WindowsProduct {
  try {
    $os = Get-CimInstance Win32_OperatingSystem
    $cap = $os.Caption
    if ($cap -match "Windows 11") { return "Windows 11" }
    if ($cap -match "Windows 10") { return "Windows 10" }
    $cap
  } catch { "Windows" }
}

function Get-HighestFeatureUpdateWin11 {
  if (-not (Ensure-PSWindowsUpdate)) { return $null }

  $fu = Get-WindowsUpdate -MicrosoftUpdate | Where-Object {
    $_.Title -match 'Feature update to Windows 11' -and $_.Title -match '\b\d{2}H[12]\b'
  }

  $versions = @()
  foreach ($u in $fu) {
    if ($u.Title -match '\b(\d{2}H[12])\b') { $versions += $Matches[1] }
  }

  $versions = $versions | Sort-Object -Unique
  if (-not $versions -or $versions.Count -eq 0) { return $null }

  ($versions | Sort-Object {
    [int]($_.Substring(0,2))*10 + (if ($_.Substring(2,2) -eq "H2") {2} else {1})
  } -Descending | Select-Object -First 1)
}

function Show-CurrentVersion {
  Show-Header

  $product = Get-WindowsProduct
  $id = Get-WinIdentity
  $currentHx = if ($id.DisplayVersion) { $id.DisplayVersion } else { "" }

  $targetHx = if ($product -eq "Windows 10") {
    "22H2"
  } else {
    $h = Get-HighestFeatureUpdateWin11
    if ($h) { $h } else { "24H2" }
  }

  $cmp = if ($currentHx) { Compare-Hx -Current $currentHx -Target $targetHx } else { "N/A" }

  Write-Host "Sistema instalado:" -ForegroundColor Cyan
  Write-Host ("Produto (detectado): {0}" -f $product)
  Write-Host ("Nome/Edicao (reg):   {0} ({1})" -f $id.ProductName, $id.EditionID)
  Write-Host ("Versao (H1/H2):      {0}" -f ($(if($currentHx){$currentHx}else{"(nao encontrado)"})))
  Write-Host ("Build:               {0}.{1}" -f $id.CurrentBuild, $id.UBR)

  Write-Host ""
  Write-Host ("Alvo sugerido:       {0}" -f $targetHx) -ForegroundColor Yellow
  Write-Host ("Status vs alvo:      {0}" -f $cmp) -ForegroundColor Yellow

  if ($product -eq "Windows 11" -and $currentHx) {
    $cmp25 = Compare-Hx -Current $currentHx -Target "25H2"
    Write-Host ("Status vs 25H2:      {0}" -f $cmp25) -ForegroundColor Yellow
  }

  Write-Log ("Versao atual: {0} | {1} | {2} | Build {3}.{4} | alvo {5} -> {6}" -f $product,$id.ProductName,$currentHx,$id.CurrentBuild,$id.UBR,$targetHx,$cmp)
  if ($product -eq "Windows 11" -and $currentHx) {
    Write-Log ("Comparativo fixo Win11: {0} vs 25H2 -> {1}" -f $currentHx, (Compare-Hx -Current $currentHx -Target "25H2"))
  }

  Pause-Script
}

function List-FeatureUpdatesWin11 {
  if (-not (Ensure-PSWindowsUpdate)) { return }

  Show-Header
  Write-Host "[INFO] Listando Feature Updates encontrados (Windows 11)..." -ForegroundColor Cyan
  Write-Log "Listagem Feature Updates (Win11)"

  $fu = Get-WindowsUpdate -MicrosoftUpdate | Where-Object { $_.Title -match 'Feature update to Windows 11' }

  if (-not $fu) {
    Write-Host "Nenhuma Feature Update apareceu nesta busca." -ForegroundColor Yellow
    Write-Host "Pode ser elegibilidade/onda de rollout." -ForegroundColor Yellow
    Pause-Script
    return
  }

  $fu | Select-Object Title, KB, Size | Format-Table -AutoSize
  Pause-Script
}

function Set-FeatureUpdateTarget {
  if (-not (Ensure-PSWindowsUpdate)) { return }

  $product = Get-WindowsProduct

  if ($product -eq "Windows 10") {
    $targetProduct = "Windows 10"
    $targetInfo = "22H2"
    Show-Header
    Write-Host "Alvo (Windows 10): $targetInfo" -ForegroundColor Cyan
    Write-Host ""
    if (-not (Confirm-YesNo "Confirmar definir alvo?")) { return }
    Write-Log "Definindo alvo: Windows 10 $targetInfo"
    Set-WUSettings -TargetReleaseVersion -TargetReleaseVersionInfo $targetInfo -ProductVersion $targetProduct
    Write-Host "[OK] Alvo definido. Rode a opcao 4 para instalar." -ForegroundColor Yellow
    Pause-Script
    return
  }

  $h = Get-HighestFeatureUpdateWin11
  $targetInfo = if ($h) { $h } else { "24H2" }
  $targetProduct = "Windows 11"

  Show-Header
  Write-Host "Feature Update alvo (Windows 11): $targetInfo" -ForegroundColor Cyan
  Write-Host "Obs: 25H2 existe (enablement package KB5054156), pode depender de elegibilidade/onda." -ForegroundColor Yellow  # [web:166]
  Write-Host ""
  if (-not (Confirm-YesNo "Confirmar definir alvo?")) { return }

  Write-Log "Definindo alvo: Windows 11 $targetInfo"
  Set-WUSettings -TargetReleaseVersion -TargetReleaseVersionInfo $targetInfo -ProductVersion $targetProduct
  Write-Host "[OK] Alvo definido. Rode a opcao 4 para instalar." -ForegroundColor Yellow
  Pause-Script
}

function Clear-FeatureUpdateTarget {
  Show-Header
  Write-Host "Isso remove a politica TargetReleaseVersion (destrava o alvo)." -ForegroundColor Yellow
  Write-Host ""
  if (-not (Confirm-YesNo "Confirmar remover alvo?")) { return }

  $key = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
  foreach ($name in "TargetReleaseVersion","TargetReleaseVersionInfo","ProductVersion") {
    try { Remove-ItemProperty -Path $key -Name $name -ErrorAction SilentlyContinue } catch {}
  }

  Write-Log "Alvo TargetReleaseVersion removido"
  Write-Host "[OK] Alvo removido." -ForegroundColor Cyan
  Pause-Script
}

function Scan-And-Install {
  if (-not (Ensure-PSWindowsUpdate)) { return }

  Show-Header
  Write-Host "[INFO] Buscando atualizacoes (Feature Update aparece se elegivel)..." -ForegroundColor Cyan
  Write-Log "Busca atualizacoes"
  Get-WindowsUpdate -MicrosoftUpdate
  Pause-Script

  Show-Header
  Write-Host "[INFO] Instalando atualizacoes..." -ForegroundColor Cyan
  Write-Log "Instalacao updates (IsServer=$IsServer)"

  if ($IsServer) {
    Install-WindowsUpdate -AcceptAll -IgnoreReboot
    Write-Host ""
    Write-Host "[SERVIDOR] Instalado sem reiniciar. Reinicie no horario de manutencao." -ForegroundColor Yellow
    Pause-Script
  } else {
    if (Confirm-YesNo "Permitir reinicio automatico se necessario?") {
      Install-WindowsUpdate -AcceptAll -AutoReboot
    } else {
      Install-WindowsUpdate -AcceptAll -IgnoreReboot
      Pause-Script
    }
  }
}

function Show-History {
  if (-not (Ensure-PSWindowsUpdate)) { return }
  Show-Header
  Write-Host "[INFO] Historico de atualizacoes:" -ForegroundColor Cyan
  Write-Log "Consulta historico"
  Get-WUHistory | Select-Object Date, Title, Result | Format-Table -AutoSize
  Pause-Script
}

Write-Log ("Feature Update Tool iniciado | IsServer={0}" -f $IsServer)

do {
  Show-Header
  Write-Host "==================== MENU FEATURE UPDATE ====================" -ForegroundColor White
  Write-Host ""
  Write-Host "1 - Mostrar versao atual (nome/edicao + H1/H2 + build + comparativos)"
  Write-Host "2 - Listar Feature Updates encontrados (Win11)"
  Write-Host "3 - Definir alvo H1/H2 (Win10=22H2 / Win11=auto maior)"
  Write-Host "4 - Buscar e instalar atualizacoes (inclui Feature Update)"
  Write-Host "5 - Historico de atualizacoes"
  Write-Host "6 - Remover alvo (destravar TargetReleaseVersion)"
  Write-Host "7 - Sair" -ForegroundColor Yellow
  Write-Host ""

  $op = Read-Host "Escolha uma opcao"

  switch ($op) {
    "1" { Show-CurrentVersion }
    "2" { List-FeatureUpdatesWin11 }
    "3" { Set-FeatureUpdateTarget }
    "4" { Scan-And-Install }
    "5" { Show-History }
    "6" { Clear-FeatureUpdateTarget }
    "7" { Write-Log "Aplicacao encerrada"; exit 0 }
    default {
      Write-Host ""
      Write-Host "[ERRO] Opcao invalida!" -ForegroundColor Yellow
      Start-Sleep 1
    }
  }
} while ($true)

Com esse tipo de abordagem, você transforma um simples script em uma ferramenta poderosa de controle e atualização do Windows.