$ErrorActionPreference = 'SilentlyContinue' if (-not $args) { Write-Host "Starting MAS..." -ForegroundColor Green } & { $psv = (Get-Host).Version.Major if ($ExecutionContext.SessionState.LanguageMode.value__ -ne 0) { Write-Host "PowerShell is not running in Full Language Mode." return } $URLs = @( 'https://raw.githubusercontent.com/jianyun-wu/Microsoft-Activation-Scripts/refs/heads/master/MAS/All-In-One-Version-KL/MAS_AIO.cmd', 'https://r2.getwin.wjy.im/MAS_AIO.cmd' ) try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch {} $response = $null foreach ($URL in $URLs) { try { if ($psv -ge 3) { $response = Invoke-RestMethod $URL -UseBasicParsing } else { $w = New-Object Net.WebClient $response = $w.DownloadString($URL) } if ($response) { break } } catch {} } if (-not $response) { Write-Host "Failed to retrieve MAS file!" -ForegroundColor Red return } $paths = "HKCU:\SOFTWARE\Microsoft\Command Processor", "HKLM:\SOFTWARE\Microsoft\Command Processor" foreach ($path in $paths) { if (Get-ItemProperty -Path $path -Name "Autorun" -ErrorAction SilentlyContinue) { Write-Warning "Autorun registry found, CMD may crash!" } } $rand = [Guid]::NewGuid().Guid $isAdmin = [bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -match 'S-1-5-32-544') $FilePath = if ($isAdmin) { "$env:SystemRoot\Temp\MAS_$rand.cmd" } else { "$env:USERPROFILE\AppData\Local\Temp\MAS_$rand.cmd" } Set-Content -Path $FilePath -Value "@::: $rand `r`n$response" if ($psv -lt 3) { $p = Start-Process -FilePath "$env:SystemRoot\system32\cmd.exe" -ArgumentList "/c """"$FilePath"" -el -qedit $args""" -Verb RunAs -PassThru $p.WaitForExit() } else { Start-Process -FilePath "$env:SystemRoot\system32\cmd.exe" -ArgumentList "/c """"$FilePath"" -el $args""" -Wait -Verb RunAs } Remove-Item -Path $FilePath -ErrorAction SilentlyContinue } @args