please see my batch file:
cd C:\Program Files (x86)\Gpg4win\bin echo "my passphrase"|gpg --always-trust --recipient abc@def.com --batch --passphrase-fd 0 --output D:\pgptest\a.txt --decrypt "d:\pgptest\b.txt"
It keeps asking me to input the passphrase even though I add it in batch file. Once I input the passphrase, it works well, but I want to my batch file running at silent mode.Please help me.
C:\Program Files (x86)\Gpg4win\bin>gpg --version
gpg (GnuPG) 2.2.4 libgcrypt 1.8.2 Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: C:/Users/xxx/AppData/Roaming/gnupg Supported algorithms: Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2
Short Answer: Add "--pinentry-mode loopback" to your command line
As noted on: https://wiki.gnupg.org/TroubleShooting#Passphrase_on_the_command_line
If you put the passphrase in a batch file anyway it usually does not make much sense to have a passphrase on your key at all. (Use gpg --passwd to remove it.) If you want to supply it on the command line you have to add the pinentry-mode argument.
Btw. "--always-trust --recipient abc@def.com" arguments are unused / make no sense together with --decrypt.