@echo off
setlocal
title SoftwareAudit - Scan this computer
set "SRV=https://softwareaudit.service.bgs.co.th"
set "D="
set "DIR=%LOCALAPPDATA%\SoftwareAudit"
if not exist "%DIR%" mkdir "%DIR%"
echo ============================================================
echo  SoftwareAudit : scan this computer and upload to %SRV%
echo  (a UAC prompt will appear - click Yes)
echo ============================================================
echo Downloading the latest scanner ...
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference='SilentlyContinue'; try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 3072 } catch {}; try { Invoke-WebRequest -UseBasicParsing ('%SRV%/scanner/SoftwareAudit.ps1') -OutFile '%DIR%\SoftwareAudit.ps1'; Invoke-WebRequest -UseBasicParsing ('%SRV%/scanner/config.txt?d=%D%') -OutFile '%DIR%\config.txt'; Get-ChildItem '%DIR%\*' | Unblock-File -ErrorAction SilentlyContinue; exit 0 } catch { Write-Host $_.Exception.Message; exit 1 }"
if errorlevel 1 (
  echo.
  echo Download failed - please check the network connection to %SRV% and try again.
  pause
  exit /b 1
)
powershell -NoProfile -ExecutionPolicy Bypass -File "%DIR%\SoftwareAudit.ps1" -Pause
