Stack Exchange
GPG unattended encryption not giving output
I have created a script which will encrypt a file using GPG and upload it to a target. 
The script is as follows:
cd C:\test\outfeeds\
echo ---------- >> C:\test\log.txt
date /T >> C:\test\log.txt
echo %time% >> C:\test\log.txt
echo %USERNAME% >> C:\test\log.txt
echo ---------- >> C:\test\log.txt
echo --- Encrypting Files --- >> C:\test\log.txt
for %%a in (*.txt) do (
  gpg --allow-weak-digest-algos -o %%a.pgp -e -r "testkey" %%a >> C:\test\log.txt
)
echo --- Transferring Files --- >> C:\test\log.txt
sftpc -profile="C:\test\FTP\test_profile.bscp" -hostKeyFile="C:\test\FTP\Host_Key_Export" -unat=y -cmd="put *.pgp inbound/ap/" >> C:\test\log.txt

del *.pgp
move *.txt C:\test\feedarchive\

The logs show nothing for the gpg call so when i run it unattended I can see it runs under a user named testmachine$.  This results in no file being available for the sftpc call (so I assume this file isn't getting made).
When I run it manually, it seems to work fine, logging nothing for the gpg call, but creating the file and uploading it successfully.
Is there a way to return what's going wrong on this call, or something obvious I am doing wrong?

You have not described how the script is running unattended.

The script is being triggered by an application running via the IIS Application pools.  I have set the pool to belong to a user which has the key imported (and trusted) but it seems to not use this user.
