"gpg.exe -se" fails when run programmatically, but does not fail when run from the command line
Closed, ResolvedPublic


We have our program running the gpg.exe command line utility and it has been working fine.
Recently and randomly it produces the following error message.

We are running

In Windows 10 (sysinfo attached)

Error message in our programs log file:

173310: Encryption command = "C:\Program Files (x86)\GnuPG\bin\gpg.exe" --compress-algo 1 --cipher-algo cast5 --armor --recipient 78A9B300 --local-user Intellisafe --trust-model always --output KFC_19072019173310793.csv.enc -se KFC_19072019173310793.csv
173334: Encryption result: failed
173334: Encryption failed. Err = Unknown error (run command externally to get more information)

If I then run the command the next day manually from the command line it completes fine with no errors.

Any ideas what this error may be?


njcooke created this task.Jul 23 2019, 1:39 AM
dkg added a subscriber: dkg.Jul 23 2019, 5:16 AM

This report doesn't contain enough information to be able to tell you why the command is failing within your program, but not failing outside of it.

If i had to guess, i'd suspect that the GnuPG homedir/keyring used by the program differs from the one used when you run it from the command line.

Is it possible that your program is running as a different user that does not have a certificate with short key ID 78A9B300 in their keyring? or maybe they're setting the GNUPGHOME environment variable?

aheinecke triaged this task as Low priority.Jul 23 2019, 9:08 AM
aheinecke added projects: gpg4win, Info Needed.
aheinecke added a subscriber: aheinecke.

I'm also not sure how to classify this issue. I'm giving it low priority for now as we do not have the info to determine if this is a program error.

Please run the command on the command line and if it fails paste the output here.

Regarding the different Homedirs dkg mentions. Maybe:


Provides some useful information for you. Please let us know if that was the problem so that we can close this issue.


Thanks aheinecke and dkg.
I havent been able to replicate the fault using the command line (using the exact same command and options that our program is calling)
however our R&D dept have,
The next time it fails and we can replicate it we will try the --homedir fix and see if thats it.
Its the same user in the program and command prompt so we dont think its a certificate issue.

Thanks again, much appreciated.

dkg renamed this task from Issue with gpg.exe to "gpg.exe -se" fails when run programmatically, but does not fail when run from the command line.Jul 23 2019, 5:43 PM

FYI here is what I did to resolve:
running gpg.exe and gpg-agent.exe as Administrator and XP mode....
set service Priority to REALTIME
Disabled Windows UAC virtualization.

One month and no issue with gpg now...
Thanks for all your help

njcooke closed this task as Resolved.Oct 1 2019, 2:48 AM
njcooke claimed this task.