@echo off rem ========================================================================== rem BT411 -- package tonight's logs into ONE Discord-attachable zip. rem Double-click me after a playtest. The zip lands on your DESKTOP as rem BTLOGS__.zip -- attach that one file in Discord. rem Collects: every session log, matchlog, and launch breadcrumb. Nothing rem is deleted or modified; this only makes a copy. rem rem Field-hardened 2026-08-15 after two testers hit different failures: rem * ConstrainedLanguage mode (locked-down Windows) blocks .NET calls, so rem [Environment]::GetFolderPath and [math]::Round are gone -- the Desktop rem is resolved from environment variables and the size via -f formatting. rem Compress-Archive ALSO fails there (it is a script module that calls rem .NET internally), so the zip is made with Windows' native tar.exe and rem Compress-Archive is only the fallback if tar is missing. rem * A log still held open by a running BattleTech made Compress-Archive rem abort the WHOLE zip. Files are now staged with Copy-Item first, so an rem unreadable one is skipped and named instead of killing the run. rem * The old script announced success unconditionally. It now only says rem the zip is ready if the file actually exists. rem ABOUT.txt (machine, date, folder, exe version) rides inside the zip so we rem can tell WHICH BUILD a report came from. rem ========================================================================== cd /d "%~dp0" powershell -NoProfile -ExecutionPolicy Bypass -Command ^ "$ErrorActionPreference = 'SilentlyContinue';" ^ "$d = Get-Date -Format yyyyMMdd_HHmm;" ^ "$desk = $null;" ^ "if ($env:OneDrive -and (Test-Path (Join-Path $env:OneDrive 'Desktop'))) { $desk = Join-Path $env:OneDrive 'Desktop' }" ^ "elseif (Test-Path (Join-Path $env:USERPROFILE 'Desktop')) { $desk = Join-Path $env:USERPROFILE 'Desktop' }" ^ "else { $desk = $PWD.Path };" ^ "$out = Join-Path $desk ('BTLOGS_{0}_{1}.zip' -f $env:COMPUTERNAME, $d);" ^ "$files = Get-ChildItem -Path 'content\*.log','content\lastrun_*.txt','content\matchlog_*.txt','content\cdb_*.txt' | Where-Object { $_.LastWriteTime -gt (Get-Date).AddHours(-36) };" ^ "if (-not $files) { Write-Host ''; Write-Host ' No logs found -- run me from the BT411 folder (the one containing content).' -ForegroundColor Yellow; exit 1 };" ^ "$stage = Join-Path $env:TEMP ('BTLOGS_' + $d);" ^ "Remove-Item -Recurse -Force $stage;" ^ "New-Item -ItemType Directory -Path $stage -Force | Out-Null;" ^ "$kept = 0; $skip = @();" ^ "foreach ($f in $files) { Copy-Item -LiteralPath $f.FullName -Destination $stage -Force; if (Test-Path (Join-Path $stage $f.Name)) { $kept = $kept + 1 } else { $skip += $f.Name } };" ^ "$exe = Get-Item 'btl4.exe';" ^ "$about = Join-Path $stage 'ABOUT.txt';" ^ "Set-Content -Path $about -Value ('machine=' + $env:COMPUTERNAME);" ^ "Add-Content -Path $about -Value ('packed=' + $d);" ^ "Add-Content -Path $about -Value ('folder=' + $PWD.Path);" ^ "if ($exe) { Add-Content -Path $about -Value ('btl4.exe built ' + $exe.LastWriteTime); if ($exe.VersionInfo.FileVersion) { Add-Content -Path $about -Value ('btl4.exe version ' + $exe.VersionInfo.FileVersion) } };" ^ "if ($kept -eq 0) { Write-Host ''; Write-Host ' Could not read any log files -- close BattleTech, then run me again.' -ForegroundColor Red; exit 1 };" ^ "Remove-Item -Force $out;" ^ "Push-Location $stage;" ^ "if (Get-Command tar.exe) { tar.exe -a -c -f $out * } ;" ^ "Pop-Location;" ^ "if (-not (Test-Path $out)) { Compress-Archive -Force -Path (Join-Path $stage '*') -DestinationPath $out };" ^ "Remove-Item -Recurse -Force $stage;" ^ "Write-Host '';" ^ "if (Test-Path $out) { Write-Host (' ZIP READY: ' + $out) -ForegroundColor Green; Write-Host (' ' + $kept + ' files, ' + ('{0:N1}' -f ((Get-Item $out).Length/1MB)) + ' MB'); if ($skip.Count -gt 0) { Write-Host (' SKIPPED (still in use): ' + ($skip -join ', ')) -ForegroundColor Yellow; Write-Host ' Close BattleTech and run me again to include those.' -ForegroundColor Yellow } }" ^ "else { Write-Host ' FAILED -- no zip was created.' -ForegroundColor Red; Write-Host ' Screenshot this window and send it to us.' -ForegroundColor Red; exit 1 }" if errorlevel 1 goto :failed echo. echo Attach that BTLOGS zip in Discord. Thanks! goto :done :failed echo. echo Nothing was created -- see the message above. :done pause