# =============================== # 远程下载 IAS 脚本执行器(中文提示版) # =============================== if (-not $args) { Write-Host "" Write-Host "需要帮助?请访问主页: " -NoNewline Write-Host "https://massgrave.dev" -ForegroundColor Green Write-Host "" } & { $psv = (Get-Host).Version.Major $troubleshoot = "https://massgrave.dev/troubleshoot" # 检查 PowerShell 完整语言模式 if ($ExecutionContext.SessionState.LanguageMode.value__ -ne 0) { Write-Host "PowerShell 没有以完全语言模式运行。" Write-Host "帮助 - https://massgrave.dev/fix_powershell" -ForegroundColor White -BackgroundColor Blue return } # 检查 .NET 环境 try { [void][System.AppDomain]::CurrentDomain.GetAssemblies(); [void][System.Math]::Sqrt(144) } catch { Write-Host "错误: $($_.Exception.Message)" -ForegroundColor Red Write-Host "PowerShell 无法加载 .NET 命令。" Write-Host "帮助 - https://massgrave.dev/in-place_repair_upgrade" -ForegroundColor White -BackgroundColor Blue return } function Check3rdAV { $cmd = if ($psv -ge 3) { "Get-CimInstance" } else { "Get-WmiObject" } $avList = & $cmd -Namespace root\SecurityCenter2 -Class AntiVirusProduct | Where-Object { $_.displayName -notlike "*windows*" } | Select-Object -ExpandProperty displayName if ($avList) { Write-Host "可能有第三方杀毒软件阻止脚本运行 - " -ForegroundColor White -BackgroundColor Blue -NoNewline Write-Host " $($avList -join ", ")" -ForegroundColor DarkRed -BackgroundColor White } } function CheckFile { param ([string]$FilePath) if (-not (Test-Path $FilePath)) { Check3rdAV Write-Host "在临时文件夹中创建 IAS 文件失败,脚本终止!" Write-Host "帮助 - $troubleshoot" -ForegroundColor White -BackgroundColor Blue throw } } try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch {} # 下载远程 IAS.cmd $url = "https://raw.githubusercontent.com/AreCie/IDM-Activation-Script/refs/heads/main/IAS.cmd" Write-Progress -Activity "下载中..." -Status "请稍候" try { if ($psv -ge 3) { $response = Invoke-RestMethod $url } else { $w = New-Object Net.WebClient; $response = $w.DownloadString($url) } } catch { Write-Host "无法下载 IAS 脚本: $($_.Exception.Message)" -ForegroundColor Red Write-Host "帮助 - $troubleshoot" -ForegroundColor White -BackgroundColor Blue return } Write-Progress -Activity "下载中..." -Status "完成" -Completed # 生成临时 CMD 文件 $rand = [Guid]::NewGuid().Guid $isAdmin = [bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -match "S-1-5-32-544") $FilePath = if ($isAdmin) { "$env:SystemRoot\Temp\IAS_$rand.cmd" } else { "$env:USERPROFILE\AppData\Local\Temp\IAS_$rand.cmd" } Set-Content -Path $FilePath -Value "@::: $rand `r`n$response" CheckFile $FilePath $env:ComSpec = "$env:SystemRoot\system32\cmd.exe" $chkcmd = & $env:ComSpec /c "echo CMD 工作正常" if ($chkcmd -notcontains "CMD 工作正常") { Write-Warning "cmd.exe 无法正常工作。`n请报告此问题: $troubleshoot" } # 执行临时 CMD 文件 if ($psv -lt 3) { if (Test-Path "$env:SystemRoot\Sysnative") { Write-Warning "当前 PowerShell 为 x86 版本,请使用 x64 PowerShell 运行..."; return } $p = saps -FilePath $env:ComSpec -ArgumentList "/c """"$FilePath"" -el -qedit $args""" -Verb RunAs -PassThru $p.WaitForExit() } else { saps -FilePath $env:ComSpec -ArgumentList "/c """"$FilePath"" -el $args""" -Wait -Verb RunAs } CheckFile $FilePath Remove-Item -Path $FilePath } @args