@echo off
setlocal
title MSA Staff Desk Update v1.14.24
echo.
echo =================================================
echo   MOHD SHAHID ^& ASSOCIATES - STAFF DESK UPDATE
echo   Version 1.14.24
echo =================================================
echo.
set "MSA_PS=%TEMP%\MSA-Staff-Desk-Update-1-14-24-%RANDOM%.ps1"
echo Downloading approved update from ca.shahidsiddiqui.in ...
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "try { [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -UseBasicParsing -Uri 'https://ca.shahidsiddiqui.in/staff-desktop-installer.php?v=1.14.24' -OutFile '%MSA_PS%'; exit 0 } catch { Write-Host $_.Exception.Message; exit 1 }"
if errorlevel 1 (
  echo.
  echo Update could not be downloaded. Your current Staff Desk is unchanged.
  pause
  exit /b 1
)
powershell.exe -NoProfile -Command "if ((Get-FileHash -Algorithm SHA256 -Path '%MSA_PS%').Hash.ToLowerInvariant() -ne 'ca772e8bb024af42ba4767726cf6666ed9db45ee999007e59eb7f3cd093bb170') { exit 1 }"
if errorlevel 1 (
  echo Installer integrity check failed. No file was installed.
  pause
  exit /b 1
)
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%MSA_PS%"
set "MSA_EXIT=%ERRORLEVEL%"
del /q "%MSA_PS%" >nul 2>nul
if not "%MSA_EXIT%"=="0" (
  echo.
  echo Update did not complete. Please contact the administrator.
  pause
)
endlocal & exit /b %MSA_EXIT%
