# This script is hosted at https://get.vst76.cn for SHAONIAN697/Microsoft-Activation-Scripts. $ErrorActionPreference = 'Stop' if (-not $args) { Write-Host '' Write-Host 'Project: ' -NoNewline Write-Host 'https://github.com/SHAONIAN697/Microsoft-Activation-Scripts' -ForegroundColor Green Write-Host '' } & { $psv = (Get-Host).Version.Major try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch {} $urls = @( 'https://get.vst76.cn/MAS/All-In-One-Version-KL/MAS_AIO.cmd', 'https://raw.githubusercontent.com/SHAONIAN697/Microsoft-Activation-Scripts/master/MAS/All-In-One-Version-KL/MAS_AIO.cmd' ) $tempFile = Join-Path $env:TEMP ("MAS_{0}.cmd" -f [guid]::NewGuid()) $expectedHash = '9F57FEB447F441AB4734A528FC526512D96BA135050D3E25E7EA4574AECC552E' $downloaded = $false $errors = @() Write-Progress -Activity 'Downloading...' -Status 'Please wait' foreach ($url in $urls) { try { if ($psv -ge 3) { Invoke-WebRequest -Uri $url -OutFile $tempFile -UseBasicParsing } else { $client = New-Object Net.WebClient $client.DownloadFile($url, $tempFile) } $actualHash = (Get-FileHash -Path $tempFile -Algorithm SHA256).Hash if ($actualHash -ne $expectedHash) { throw "Integrity check failed for $url. Expected $expectedHash, received $actualHash." } $downloaded = $true break } catch { $errors += $_ Remove-Item -LiteralPath $tempFile -Force -ErrorAction SilentlyContinue } } Write-Progress -Activity 'Downloading...' -Status 'Done' -Completed if (-not $downloaded) { foreach ($downloadError in $errors) { Write-Host "Error: $($downloadError.Exception.Message)" -ForegroundColor Red } throw 'Failed to retrieve MAS from all available mirrors.' } try { $env:ComSpec = "$env:SystemRoot\system32\cmd.exe" Start-Process -FilePath $env:ComSpec -ArgumentList "/c `"`"$tempFile`" -el $args`"" -Wait -Verb RunAs } finally { Remove-Item -LiteralPath $tempFile -Force -ErrorAction SilentlyContinue } } @args