posimai-root/tools/pc-audit/Run-Portable.bat

26 lines
838 B
Batchfile

@echo off
setlocal
cd /d "%~dp0"
echo.
echo === Posimai PC Audit (portable) ===
echo.
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0Invoke-PcAudit.ps1"
if errorlevel 1 (
echo.
echo ERROR: Audit failed. PowerShell 5.1+ is required.
pause
exit /b 1
)
echo.
echo Opening report viewer...
powershell -NoProfile -Command ^
"$j=[System.IO.File]::ReadAllText('%~dp0out\latest.json',[System.Text.Encoding]::UTF8);" ^
"$t=[System.IO.File]::ReadAllText('%~dp0report-viewer.html',[System.Text.Encoding]::UTF8);" ^
"$s='<script>window.__AUDIT_PRELOAD__='+$j+';</script>';" ^
"$o=$t.Replace('<!-- AUDIT_PRELOAD -->',$s);" ^
"$p=[System.IO.Path]::Combine([System.IO.Path]::GetTempPath(),'pc-audit-report.html');" ^
"[System.IO.File]::WriteAllText($p,$o,[System.Text.Encoding]::UTF8);" ^
"Start-Process $p"
echo.
pause