@echo off
setlocal
set "LOG=%USERPROFILE%\Desktop\DirectPay_GPG_Discovery.txt"

REM Auto-detect Program Files path
IF DEFINED PROCESSOR_ARCHITEW6432 (
  REM Running 32-bit process on 64-bit Windows
  set "GPG_EXE=%ProgramFiles(x86)%\DirectPay\GnuPG\gpg.exe"
) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
  REM Running 64-bit process on 64-bit Windows
  set "GPG_EXE=%ProgramFiles%\DirectPay\GnuPG\gpg.exe"
) ELSE (
  REM 32-bit Windows
  set "GPG_EXE=%ProgramFiles%\DirectPay\GnuPG\gpg.exe"
)

set "GNUPG_HOME=%ProgramData%\DirectPay\GnuPG"

>%LOG% echo === DirectPay GPG Discovery ===
>>%LOG% echo GPG_EXE   = %GPG_EXE%
>>%LOG% echo GNUPG_HOME= %GNUPG_HOME%
>>%LOG% echo.
if exist "%GPG_EXE%" (
  "%GPG_EXE%" --homedir "%GNUPG_HOME%" --version >>"%LOG%" 2>&1
  echo.>>"%LOG%"
  "%GPG_EXE%" --homedir "%GNUPG_HOME%" --list-keys >>"%LOG%" 2>&1
) else (
  >>%LOG% echo gpg.exe not found at that path.
)
start notepad "%LOG%"