Gpg4win Decoded

I previously posted about a script I put together to decrypt and rename a gpg file. Part of the odyssey traveled to create that script involved attempting to put together the arguments to make gpg4win decrypt the file as an unattended task.

The amount of useful and helpful information in the README file for gpg4win is almost equal to the number of pink elephants sitting on my desk right now. I managed to finally piece it together and figure out how to pipe the passphrase into it. Here’s how I did it and what worked for me.

echo passphrase|gpg --batch --passphrase-fd 0 --output filename.txt -d c:\path\*.gpg


– If I remember correctly, you need to use the –batch switch in order for it to work correctly in Scheduled Tasks.
– The “-d” argument tells it to decrypt.
– If you either pipe your passphrase to gpg and don’t include the “–passphrase-fd 0” switch or vice versa, you will still be prompted to enter your passphrase when the script runs. You must pipe the passphrase at the beginning AND include the –passphrase switch.
– The “–passphrase-fd” switch isn’t included in the -help list in the command-line, so if you’re having trouble automating it, this is probably the piece you’re missing.

Other than that, I can’t seem to find my documentation on why that particular set of switches works for me. The README file is useless and the Novice manual doesn’t include anything about command-line switches. I know there is a comprehensive list somewhere out there on the internets, so if anyone has run across it, please post the link in a comment and I’ll update this post.

VN:F [1.9.22_1171]
Rating: 5.0/5 (2 votes cast)
Gpg4win Decoded, 5.0 out of 5 based on 2 ratings
Want to share?
This entry was posted in Techy Stuff and tagged , , , , , , , , , . Bookmark the permalink.

6 Responses to Gpg4win Decoded

  1. Bret Miskin says:

    If I reword a news article is that copyright ?

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • tgnp says:

      No. Copyright is “the exclusive legal right, given to an originator or an assignee to print, publish, perform, film, or record literary, artistic, or musical material, and to authorize others to do the same”.

      I believe the word you’re searching for is either “plagiarism” or “unoriginality” (which could be a word I just made up on the spot). However, my legal counsel suggests that if you are going to reword an article, to at least provide the source to cover your butt. (Have you read The Bloggess? She wants to sue err’body!)

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  2. Bryce Yates says:

    The code works great! Do you know if there is a way to make the output file name dynamic or rather based upon the decrypted file name. I’ve tried the following for the output syntax, but get an error. –output c:\test\*.pdf

    Thoughts? Thanks for the assist

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  3. doug says:

    thanks for the tip. it might be worth noting that there must be no space between the passcode and the pipe.

    The code here is correct. But I typed it as echo passcode | gpg …

    The command interpreter must have included the space in my passcode and the decrypt failed.

    After figuring that out, this works great. Thanks again.

    VA:F [1.9.22_1171]
    Rating: +2 (from 2 votes)
  4. Mark says:

    I found this helpful site:

    But the real gem is the hint at the bottom:
    “Most importantly, don’t forget that the syntax of all of GPG’s commands is given in detail in the file, included with GPG.”
    I found a gpg2.mem file of the 2.1 install in:

    hope that helps

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply

Your email address will not be published.