# JhyBook DayZ mod installer — generated from the current server mod list $ErrorActionPreference = 'Stop' $mods = @('1559212036', '2545327648', '2291785308', '2792982069', '2828486817', '2572324799', '2792984722', '2792983364', '2792982897', '2811159859', '2064159537', '3655699332', '1711179264', '1565871491', '1560819773', '1828439124', '1819514788', '1710977250', '1646187754', '1870524790', '3789105982', '3200745813', '3707663156', '3718035516', '3657747578', '2903723881', '3193673221', '3425963998', '3332001143', '3491661516', '1602372402', '1663971788') $appId = '221100' $candidates = @() $roots = @("$env:ProgramFiles(x86)\Steam", "$env:ProgramFiles\Steam") | Where-Object { $_ -and (Test-Path $_) } foreach ($root in $roots) { $candidates += $root $vdf = Join-Path $root 'steamapps\libraryfolders.vdf' if (Test-Path $vdf) { $matches = [regex]::Matches((Get-Content $vdf -Raw), '"path"\s+"([^"]+)"') foreach ($match in $matches) { $candidates += $match.Groups[1].Value.Replace('\\','\') } } } $libraries = @($candidates | Select-Object -Unique | Where-Object { Test-Path (Join-Path $_ 'steamapps\appmanifest_221100.acf') }) if (!$libraries.Count) { $libraries = @($candidates | Select-Object -Unique) } if (!$libraries.Count) { throw '未找到 Steam 库。请先安装 Steam 与 DayZ。' } Write-Host "`n可用 Steam 库:" -ForegroundColor Cyan for ($i=0; $i -lt $libraries.Count; $i++) { Write-Host "[$i] $($libraries[$i])" } $choice = Read-Host '选择安装 DayZ 的 Steam 库编号' if ($choice -notmatch '^\d+$' -or [int]$choice -ge $libraries.Count) { throw '选择无效。' } $library = $libraries[[int]$choice] $steamcmdDir = Join-Path $library 'SteamCMD' $steamcmd = Join-Path $steamcmdDir 'steamcmd.exe' if (!(Test-Path $steamcmd)) { New-Item -ItemType Directory -Force -Path $steamcmdDir | Out-Null $zip = Join-Path $env:TEMP 'steamcmd.zip' Write-Host '正在下载 SteamCMD…' -ForegroundColor Cyan Invoke-WebRequest 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip' -OutFile $zip Expand-Archive -Force $zip $steamcmdDir } $steamUser = Read-Host 'Steam 帐号名称(密码与 Steam Guard 将由 SteamCMD 在安全终端内询问)' if (![string]::IsNullOrWhiteSpace($steamUser)) { $arguments = @('+force_install_dir', $library, '+login', $steamUser) foreach ($mod in $mods) { $arguments += @('+workshop_download_item', $appId, $mod, 'validate') } $arguments += '+quit' & $steamcmd @arguments if ($LASTEXITCODE -ne 0) { throw "SteamCMD 退出代码:$LASTEXITCODE" } } Write-Host "`n完成:已按当前服务器清单处理 $($mods.Count) 个模组。重新打开 DayZ 启动器后即可加入。" -ForegroundColor Green