Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing Add-Type -AssemblyName System.IO.Compression.FileSystem function Get-CoreinfoText { param( [Parameter(Mandatory=$true)] [string]$CoreinfoPath ) $quotedExe = '"' + $CoreinfoPath + '"' $cmdLine = "/d /u /c $quotedExe -accepteula -f" $psi = New-Object System.Diagnostics.ProcessStartInfo $psi.FileName = "cmd.exe" $psi.Arguments = $cmdLine $psi.UseShellExecute = $false $psi.RedirectStandardOutput = $true $psi.RedirectStandardError = $true $psi.CreateNoWindow = $true $psi.WorkingDirectory = [System.IO.Path]::GetDirectoryName($CoreinfoPath) $p = New-Object System.Diagnostics.Process $p.StartInfo = $psi try { [void]$p.Start() $stdout = $p.StandardOutput.ReadToEnd() $stderr = $p.StandardError.ReadToEnd() $p.WaitForExit() } catch { return "" } finally { if ($p) { $p.Dispose() } } $text = ($stdout + "`n" + $stderr) if ([string]::IsNullOrWhiteSpace($text)) { return "" } $text = $text -replace "`0", "" $text = $text -replace "`r`n", "`n" $text = $text -replace "`r", "`n" return $text.Trim() } function Get-FeatureLine { param( [Parameter(Mandatory=$true)] [string]$Text, [Parameter(Mandatory=$true)] [string]$FeatureName ) $escaped = [regex]::Escape($FeatureName) $line = $Text -split "`n" | Where-Object { $_ -match "^\s*$escaped\b" } | Select-Object -First 1 if ($null -eq $line) { return "" } return ($line -replace "`0", "").TrimEnd() } function Get-FeatureState { param( [Parameter(Mandatory=$true)] [string]$Text, [Parameter(Mandatory=$true)] [string]$FeatureName ) $line = Get-FeatureLine -Text $Text -FeatureName $FeatureName if ([string]::IsNullOrWhiteSpace($line)) { return "N/D" } $escaped = [regex]::Escape($FeatureName) if ($line -match "^\s*$escaped\b\s+\*") { return "Sì" } if ($line -match "^\s*$escaped\b\s+-") { return "No" } return "N/D" } function Show-Report($arch, $popcnt, $sse42, $finalMessage, $color, $isUpgradable) { $form = New-Object System.Windows.Forms.Form $form.Text = "Verifica Compatibilità Windows 11" $form.StartPosition = "CenterScreen" $form.Size = New-Object System.Drawing.Size(700,400) $form.Topmost = $true $form.FormBorderStyle = 'FixedDialog' $form.MaximizeBox = $false $form.MinimizeBox = $true $form.ShowIcon = $false $fontNormal = New-Object System.Drawing.Font("Segoe UI",12,[System.Drawing.FontStyle]::Regular) $fontBold = New-Object System.Drawing.Font("Segoe UI",12,[System.Drawing.FontStyle]::Bold) $fontFinal = New-Object System.Drawing.Font("Segoe UI",14,[System.Drawing.FontStyle]::Bold) $fontLink = New-Object System.Drawing.Font("Segoe UI",11,[System.Drawing.FontStyle]::Underline) $lblFinal = New-Object System.Windows.Forms.Label $lblFinal.Text = $finalMessage $lblFinal.Font = $fontFinal $lblFinal.ForeColor = $color $lblFinal.AutoSize = $true $lblFinal.Location = New-Object System.Drawing.Point(20,20) $lblPopcnt = New-Object System.Windows.Forms.Label $lblPopcnt.Text = "Supporto POPCNT:" $lblPopcnt.Font = $fontNormal $lblPopcnt.AutoSize = $true $lblPopcnt.Location = New-Object System.Drawing.Point(20,80) $lblPopcntVal = New-Object System.Windows.Forms.Label $lblPopcntVal.Text = $popcnt $lblPopcntVal.Font = $fontNormal $lblPopcntVal.ForeColor = if ($popcnt -eq "Sì") { [System.Drawing.Color]::Green } elseif ($popcnt -eq "No") { [System.Drawing.Color]::Red } else { [System.Drawing.Color]::DarkOrange } $lblPopcntVal.AutoSize = $true $lblPopcntVal.Location = New-Object System.Drawing.Point(200,80) $lblSse42 = New-Object System.Windows.Forms.Label $lblSse42.Text = "Supporto SSE4.2:" $lblSse42.Font = $fontNormal $lblSse42.AutoSize = $true $lblSse42.Location = New-Object System.Drawing.Point(20,120) $lblSse42Val = New-Object System.Windows.Forms.Label $lblSse42Val.Text = $sse42 $lblSse42Val.Font = $fontNormal $lblSse42Val.ForeColor = if ($sse42 -eq "Sì") { [System.Drawing.Color]::Green } elseif ($sse42 -eq "No") { [System.Drawing.Color]::Red } else { [System.Drawing.Color]::DarkOrange } $lblSse42Val.AutoSize = $true $lblSse42Val.Location = New-Object System.Drawing.Point(200,120) $lblArch = New-Object System.Windows.Forms.Label $lblArch.Text = "Architettura:" $lblArch.Font = $fontNormal $lblArch.AutoSize = $true $lblArch.Location = New-Object System.Drawing.Point(20,160) $lblArchVal = New-Object System.Windows.Forms.Label $lblArchVal.Text = $arch $lblArchVal.Font = $fontBold $lblArchVal.ForeColor = [System.Drawing.Color]::Black $lblArchVal.AutoSize = $true $lblArchVal.Location = New-Object System.Drawing.Point(200,160) if ($isUpgradable) { $picInfo = New-Object System.Windows.Forms.PictureBox $picInfo.Size = New-Object System.Drawing.Size(32,32) $picInfo.Location = New-Object System.Drawing.Point(20,210) $picInfo.Image = [System.Drawing.SystemIcons]::Information.ToBitmap() $picInfo.SizeMode = "StretchImage" $link1 = New-Object System.Windows.Forms.LinkLabel $link1.Text = "Creare un supporto USB universale per l'installazione di Windows 11" $link1.Font = $fontLink $link1.LinkColor = [System.Drawing.Color]::Blue $link1.AutoSize = $true $link1.Location = New-Object System.Drawing.Point(70,215) [void]$link1.Links.Add(0,$link1.Text.Length,"https://www.ilsoftware.it/focus/windows-11-su-pc-non-compatibile-con-rufus-la-verita-che-pochi-conoscono/") $link1.add_LinkClicked({ Start-Process $_.Link.LinkData }) $link2 = New-Object System.Windows.Forms.LinkLabel $link2.Text = "Creare una ISO di Windows 11 universale" $link2.Font = $fontLink $link2.LinkColor = [System.Drawing.Color]::Blue $link2.AutoSize = $true $link2.Location = New-Object System.Drawing.Point(70,245) [void]$link2.Links.Add(0,$link2.Text.Length,"https://www.ilsoftware.it/focus/windows-11-senza-limiti-trucco-segreto-per-modificare-la-iso-e-installarlo-ovunque/") $link2.add_LinkClicked({ Start-Process $_.Link.LinkData }) $form.Controls.AddRange(@($picInfo,$link1,$link2)) } $btnClose = New-Object System.Windows.Forms.Button $btnClose.Text = "Chiudi" $btnClose.Size = New-Object System.Drawing.Size(100,35) $btnClose.Location = New-Object System.Drawing.Point(560,310) $btnClose.Font = $fontNormal $btnClose.Add_Click({ $form.Close() }) $form.AcceptButton = $btnClose $form.Controls.AddRange(@( $lblFinal,$lblPopcnt,$lblPopcntVal,$lblSse42,$lblSse42Val,$lblArch,$lblArchVal,$btnClose )) $form.Add_Shown({ $form.Activate() }) [void]$form.ShowDialog() } $cpuAddressWidth = (Get-CimInstance Win32_Processor | Select-Object -First 1).AddressWidth $osArch = (Get-CimInstance Win32_OperatingSystem).OSArchitecture if ($cpuAddressWidth -ne 64 -and $osArch -notmatch "ARM64") { Show-Report "Non supportata" "N/D" "N/D" "Non è possibile aggiornare a Windows 11: architettura non supportata" ([System.Drawing.Color]::Red) $false exit } $coreinfoZip = Join-Path $env:TEMP "Coreinfo.zip" $coreinfoDir = Join-Path $env:TEMP "coreinfo-temp" $coreinfoUrl = "https://download.sysinternals.com/files/Coreinfo.zip" Remove-Item $coreinfoZip -Force -ErrorAction SilentlyContinue Remove-Item $coreinfoDir -Recurse -Force -ErrorAction SilentlyContinue $wc = New-Object System.Net.WebClient $wc.DownloadFile($coreinfoUrl, $coreinfoZip) New-Item -ItemType Directory -Path $coreinfoDir -Force | Out-Null [System.IO.Compression.ZipFile]::ExtractToDirectory($coreinfoZip, $coreinfoDir) $coreinfoExe = if ([Environment]::Is64BitOperatingSystem) { $candidate64 = Join-Path $coreinfoDir "coreinfo64.exe" if (Test-Path $candidate64) { $candidate64 } else { Join-Path $coreinfoDir "coreinfo.exe" } } else { Join-Path $coreinfoDir "coreinfo.exe" } if (-not (Test-Path $coreinfoExe)) { [System.Windows.Forms.MessageBox]::Show("Impossibile trovare l'eseguibile di Coreinfo dopo l'estrazione.") exit } $coreinfoText = Get-CoreinfoText -CoreinfoPath $coreinfoExe if ([string]::IsNullOrWhiteSpace($coreinfoText)) { [System.Windows.Forms.MessageBox]::Show("Impossibile leggere l'output di Coreinfo.") exit } # Debug utile: # $debugFile = Join-Path $env:TEMP "coreinfo-debug.txt" # $coreinfoText | Set-Content -Path $debugFile -Encoding UTF8 # Start-Process notepad.exe $debugFile $popcnt = Get-FeatureState -Text $coreinfoText -FeatureName "POPCNT" $sse42 = Get-FeatureState -Text $coreinfoText -FeatureName "SSE4.2" if ($popcnt -eq "Sì" -and $sse42 -eq "Sì") { $finalMessage = "Il processore supporta POPCNT e SSE4.2" $color = [System.Drawing.Color]::Green $isUpgradable = $true } elseif ($popcnt -eq "N/D" -or $sse42 -eq "N/D") { $finalMessage = "Impossibile determinare con certezza il supporto CPU richiesto" $color = [System.Drawing.Color]::DarkOrange $isUpgradable = $false } else { $finalMessage = "Il processore non espone entrambe le feature richieste" $color = [System.Drawing.Color]::Red $isUpgradable = $false } Show-Report $osArch $popcnt $sse42 $finalMessage $color $isUpgradable Remove-Item $coreinfoZip -Force -ErrorAction SilentlyContinue Remove-Item $coreinfoDir -Recurse -Force -ErrorAction SilentlyContinue