cls [Console]::InputEncoding = [System.Text.Encoding]::UTF8 Write-Host -NoNewline " _____ _____ _____ _____ _____ `r" -ForegroundColor:blue Write-Host -NoNewline " /\ \ /\ \ /\ \ /\ \ /\ \ `r" -ForegroundColor:blue Write-Host -NoNewline " /::\ \ /::\ \ /::\ \ /::\ \ /::\____\ `r" -ForegroundColor:blue Write-Host -NoNewline " /::::\ \ \:::\ \ /::::\ \ /::::\ \ /::::| | `r" -ForegroundColor:blue Write-Host -NoNewline " /::::::\ \ \:::\ \ /::::::\ \ /::::::\ \ /:::::| | `r" -ForegroundColor:blue Write-Host -NoNewline " /:::/\:::\ \ \:::\ \ /:::/\:::\ \ /:::/\:::\ \ /::::::| | `r" -ForegroundColor:blue Write-Host -NoNewline " /:::/__\:::\ \ \:::\ \ /:::/__\:::\ \ /:::/__\:::\ \ /:::/|::| | `r" -ForegroundColor:blue Write-Host -NoNewline " \:::\ \:::\ \ /::::\ \ /::::\ \:::\ \ /::::\ \:::\ \ /:::/ |::| | `r" -ForegroundColor:blue Write-Host -NoNewline " ___\:::\ \:::\ \ /::::::\ \ /::::::\ \:::\ \ /::::::\ \:::\ \ /:::/ |::|___|______ `r" -ForegroundColor:blue Write-Host -NoNewline " /\ \:::\ \:::\ \ /:::/\:::\ \ /:::/\:::\ \:::\ \ /:::/\:::\ \:::\ \ /:::/ |::::::::\ \ `r" -ForegroundColor:blue Write-Host -NoNewline "/::\ \:::\ \:::\____\ /:::/ \:::\____\/:::/__\:::\ \:::\____\/:::/ \:::\ \:::\____\/:::/ |:::::::::\____\`r" -ForegroundColor:blue Write-Host -NoNewline "\:::\ \:::\ \::/ / /:::/ \::/ /\:::\ \:::\ \::/ /\::/ \:::\ /:::/ /\::/ / ~~~~~/:::/ /`r" -ForegroundColor:blue Write-Host -NoNewline " \:::\ \:::\ \/____/ /:::/ / \/____/ \:::\ \:::\ \/____/ \/____/ \:::\/:::/ / \/____/ /:::/ / `r" -ForegroundColor:blue Write-Host -NoNewline " \:::\ \:::\ \ /:::/ / \:::\ \:::\ \ \::::::/ / /:::/ / `r" -ForegroundColor:blue Write-Host -NoNewline " \:::\ \:::\____\ /:::/ / \:::\ \:::\____\ \::::/ / /:::/ / `r" -ForegroundColor:blue Write-Host -NoNewline " \:::\ /:::/ / \::/ / \:::\ \::/ / /:::/ / /:::/ / `r" -ForegroundColor:blue Write-Host -NoNewline " \:::\/:::/ / \/____/ \:::\ \/____/ /:::/ / /:::/ / `r" -ForegroundColor:blue Write-Host -NoNewline " \::::::/ / \:::\ \ /:::/ / /:::/ / `r" -ForegroundColor:blue Write-Host -NoNewline " \::::/ / \:::\____\ /:::/ / /:::/ / `r" -ForegroundColor:blue Write-Host -NoNewline " \::/ / \::/ / \::/ / \::/ / `r" -ForegroundColor:blue Write-Host -NoNewline " \/____/ \/____/ \/____/ \/____/ `r" -ForegroundColor:blue $localPath = Join-Path $env:LOCALAPPDATA "steam" $steamRegPath = "HKCU:\Software\Valve\Steam" $steamToolsRegPath = "HKCU:\Software\Valve\Steamtools" $steamPath = "" function Remove-ItemIfExists($path) { if (Test-Path $path) { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue } } function ForceStopProcess($processName) { Get-Process $processName -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 2 if (Get-Process $processName -ErrorAction SilentlyContinue) { Start-Process cmd -ArgumentList "/c taskkill /f /im $processName.exe" -WindowStyle Hidden -ErrorAction SilentlyContinue } } function CheckAndPromptProcess($processName, $message) { while (Get-Process $processName -ErrorAction SilentlyContinue) { Write-Host $message -ForegroundColor Red Start-Sleep 1.5 } } $filePathToDelete = Join-Path $env:USERPROFILE "get.ps1" Remove-ItemIfExists $filePathToDelete ForceStopProcess "steam" if (Get-Process "steam" -ErrorAction SilentlyContinue) { CheckAndPromptProcess "Steam" "[请先退出 Steam 客户端]" } if (Test-Path $steamRegPath) { $properties = Get-ItemProperty -Path $steamRegPath -ErrorAction SilentlyContinue if ($properties -and 'SteamPath' -in $properties.PSObject.Properties.Name) { $steamPath = $properties.SteamPath } } if ([string]::IsNullOrWhiteSpace($steamPath)) { Write-Host "未找到 Steam 客户端。请安装 Steam 后重试。" -ForegroundColor Red Start-Sleep 10 exit } if (-not (Test-Path $steamPath -PathType Container)) { Write-Host "未找到 Steam 客户端。请安装 Steam 后重试。" -ForegroundColor Red Start-Sleep 10 exit } $steamConfigPath = Join-Path $steamPath "config" function Get-LatestSteamUser { param( [string]$SteamPath ) $loginUsersPath = Join-Path $SteamPath "config\loginusers.vdf" if (-not (Test-Path $loginUsersPath)) { return $null } try { $content = Get-Content $loginUsersPath -Raw -Encoding UTF8 if (-not $content) { return $null } $users = @() $userId = $null $accountName = $null $mostRecent = $null $timestamp = $null $inUserBlock = $false $lines = $content -split "`n" foreach ($line in $lines) { if ($line -match '^\s*"(\d{17})"\s*$') { if ($userId -and $accountName) { $users += [PSCustomObject]@{ UserId = $userId AccountName = $accountName MostRecent = $mostRecent -eq "1" Timestamp = [int]$timestamp } } $userId = $matches[1] $accountName = $null $mostRecent = "0" $timestamp = "0" $inUserBlock = $true } elseif ($line -match '^\s*"\d+"\s*\{') { $userId = ($line -split '"')[1] $accountName = $null $mostRecent = "0" $timestamp = "0" $inUserBlock = $true } elseif ($inUserBlock -and $line -match '"PersonaName"\s+"([^"]+)"') { $accountName = $matches[1].Trim() } elseif ($inUserBlock -and $line -match '"AccountName"\s+"([^"]+)"') { if (-not $accountName) { $accountName = $matches[1].Trim() } } elseif ($inUserBlock -and $line -match '"MostRecent"\s+"([^"]+)"') { $mostRecent = $matches[1] } elseif ($inUserBlock -and $line -match '"Timestamp"\s+"(\d+)"') { $timestamp = $matches[1] } elseif ($inUserBlock -and $line -match '^\s*\}') { $inUserBlock = $false } } if ($userId -and $accountName) { $users += [PSCustomObject]@{ UserId = $userId AccountName = $accountName MostRecent = $mostRecent -eq "1" Timestamp = [int]$timestamp } } if ($users.Count -eq 0) { return $null } $latestUser = $users | Sort-Object -Property Timestamp -Descending | Select-Object -First 1 return $latestUser } catch { return $null } } function Download-FilesByActivationCode { param( [string]$ActivationCode, [string]$SteamPath, [string]$UserId, [string]$AccountName ) $BaseUrl = "https://steam.yuyun.run" $luaTargetDir = Join-Path $SteamPath "config\stplug-in" $manifestTargetDir = Join-Path $SteamPath "depotcache" if (-not (Test-Path $luaTargetDir)) { try { New-Item -ItemType Directory -Path $luaTargetDir -Force | Out-Null } catch { return $false } } if (-not (Test-Path $manifestTargetDir)) { try { New-Item -ItemType Directory -Path $manifestTargetDir -Force | Out-Null } catch { return $false } } try { $url = "$BaseUrl/api/download_all/$($ActivationCode.Trim())" $params = @() if ($UserId) { $params += "user_id=$([Uri]::EscapeDataString($UserId.Trim()))" } if ($AccountName) { $params += "username=$([Uri]::EscapeDataString($AccountName.Trim()))" } if ($params.Count -gt 0) { $url += "?" + ($params -join "&") } $response = Invoke-RestMethod -Uri $url -Method Get -UseBasicParsing -TimeoutSec 10 if (-not $response.success) { return $false } $downloadLinks = $response.download_links $successCount = 0 foreach ($fileInfo in $downloadLinks) { $filename = $fileInfo.filename $downloadUrl = "$BaseUrl$($fileInfo.download_url)" try { $fileResponse = Invoke-WebRequest -Uri $downloadUrl -Method Get -UseBasicParsing if ($fileResponse.StatusCode -eq 200) { if ($filename -like "*.manifest") { $filePath = Join-Path $manifestTargetDir $filename } else { $filePath = Join-Path $luaTargetDir $filename } [System.IO.File]::WriteAllBytes($filePath, $fileResponse.Content) $successCount++ } } catch { } } if ($successCount -gt 0) { $luaDir = Join-Path $SteamPath "config\lua" if (-not (Test-Path $luaDir)) { New-Item -ItemType Directory -Path $luaDir -Force | Out-Null } $luaFiles = Get-ChildItem -Path $luaTargetDir -Filter "*.lua" -ErrorAction SilentlyContinue if ($luaFiles) { foreach ($luaFile in $luaFiles) { $destinationPath = Join-Path $luaDir $luaFile.Name Copy-Item -Path $luaFile.FullName -Destination $destinationPath -Force -ErrorAction SilentlyContinue } } } return $successCount -gt 0 } catch { return $false } } function Prompt-ActivationCode { Write-Host "" $activationCode = Read-Host -Prompt "请输入激活码" return $activationCode } function PwStart { try { if (!$steamPath) { return } $latestUser = Get-LatestSteamUser -SteamPath $steamPath if ($latestUser) { Write-Host "=============================================================================" -ForegroundColor Cyan Write-Host "[检测到最新Steam用户: $($latestUser.AccountName) (ID: $($latestUser.UserId))]" -ForegroundColor Cyan Write-Host "=============================================================================" -ForegroundColor Cyan } else { Write-Host "=============================================" -ForegroundColor Red Write-Host "[错误] 无法读取Steam用户信息。请先登录Steam。" -ForegroundColor Red Write-Host "=============================================" -ForegroundColor Red Start-Sleep -Seconds 5 return } $activationValid = $false while (-not $activationValid) { $activationCode = Prompt-ActivationCode if ($activationCode) { $downloadResult = Download-FilesByActivationCode -ActivationCode $activationCode -SteamPath $steamPath -UserId $latestUser.UserId -AccountName $latestUser.AccountName if ($downloadResult) { $activationValid = $true Write-Host "[激活码验证成功,已连接到Steam激活服务器。请等待Steam重启。]" -ForegroundColor Green Write-Host "=================================================" -ForegroundColor Green Write-Host "无需在Steam客户端中手动激活,直接去库里查找游戏。" -ForegroundColor Green Write-Host "=================================================" -ForegroundColor Green Start-Sleep -Seconds 2 } else { Write-Host "[激活码错误,请重新输入!]" -ForegroundColor Red Start-Sleep -Seconds 2 } } else { break } } if ($activationValid) { if (!(Test-Path $localPath)) { New-Item $localPath -ItemType Directory -Force -ErrorAction SilentlyContinue } $hidPath = Join-Path $steamPath "xinput1_4.dll" Remove-ItemIfExists $hidPath $dwmapiPath = Join-Path $steamPath "dwmapi.dll" Remove-ItemIfExists $dwmapiPath $xinputPath = Join-Path $steamPath "user32.dll" Remove-ItemIfExists $xinputPath $steamCfgPath = Join-Path $steamPath "steam.cfg" Remove-ItemIfExists $steamCfgPath $steamBetaPath = Join-Path $steamPath "package\beta" Remove-ItemIfExists $steamBetaPath $catchPath = Join-Path $env:LOCALAPPDATA "Microsoft\Tencent" Remove-ItemIfExists $catchPath try { Add-MpPreference -ExclusionPath $hidPath -ErrorAction SilentlyContinue } catch {} $versionDllPath = Join-Path $steamPath "version.dll" Remove-ItemIfExists $versionDllPath $OpenSteamToolPath = Join-Path $steamPath "OpenSteamTool.dll" Remove-ItemIfExists $OpenSteamToolPath $hidDllPath = Join-Path $steamPath "hid.dll" Remove-ItemIfExists $hidDllPath $zlibPath = Join-Path $steamPath "zlib1.dll" Remove-ItemIfExists $zlibPath $downloadHidDll = "https://update.steamfn.com/update" try { Invoke-RestMethod -Uri $downloadHidDll -OutFile $hidPath -ErrorAction Stop } catch { if (Test-Path $hidPath) { Move-Item -Path $hidPath -Destination "$hidPath.old" -Force -ErrorAction SilentlyContinue } Invoke-RestMethod -Uri $downloadHidDll -OutFile $hidPath -ErrorAction SilentlyContinue } $dwmapiPath = Join-Path $steamPath "dwmapi.dll" $downloadDwmapi = "http://update.steamfn.com/dwmapi" try { Add-MpPreference -ExclusionPath $dwmapiPath -ErrorAction SilentlyContinue } catch {} try { Invoke-RestMethod -Uri $downloadDwmapi -OutFile $dwmapiPath -ErrorAction Stop } catch { if (Test-Path $dwmapiPath) { Move-Item -Path $dwmapiPath -Destination "$dwmapiPath.old" -Force -ErrorAction SilentlyContinue } Invoke-RestMethod -Uri $downloadDwmapi -OutFile $dwmapiPath -ErrorAction SilentlyContinue } if (!(Test-Path $steamToolsRegPath)) { New-Item -Path $steamToolsRegPath -Force | Out-Null } Remove-ItemProperty -Path $steamToolsRegPath -Name "ActivateUnlockMode" -ErrorAction SilentlyContinue Remove-ItemProperty -Path $steamToolsRegPath -Name "AlwaysStayUnlocked" -ErrorAction SilentlyContinue Remove-ItemProperty -Path $steamToolsRegPath -Name "notUnlockDepot" -ErrorAction SilentlyContinue Set-ItemProperty -Path $steamToolsRegPath -Name "iscdkey" -Value "true" -Type String $steamExePath = Join-Path $steamPath "steam.exe" Start-Process $steamExePath Start-Process "steam://" for ($i = 5; $i -ge 0; $i--) { Write-Host "`r[本窗口将在 $i 秒后关闭...]" -NoNewline Start-Sleep -Seconds 1 } } exit } catch { } } PwStart