Jump to content

SOLVED trying to automate GPG...


Recommended Posts

Hi, I can encrypt files with GPG from the command line just perfect. However, if I try it from the script, I get a flash of a cmd window and nothing happens - no output file, etc. If there is an error, I can't see it because the cmd window is gone too quickly. here's the code I'm working with... should be simple enough, but I'm very likely doing it all wrong :) Any ideas would be helpful.

; #SCRIPT# ====================================================================================================


================
; Name...........:  EncryptFile.au3
; Description ...:  Encrypts files with GPG via command line.
; Syntax.........:  N/A
; Parameters ....:  $CmdLine[1] is the NAME of the key to use, $CmdLine[2] is the file to encrypt
; Return values .:  Writes out to a log of chosen in this script
; Author ........:  Jack 
; Modified.......:  13 Feb, 2008
; Remarks .......:  This is a work in progress
; Related .......:  
; Link ..........; 
; Example .......;
; ====================================================================================================


===========================
; Command that works fine - overwrites files, asks no questions.  you need to have the key signed.
; Y:\>gpg --yes --batch --recipient "info@some-office.com"  -e THE_demographic_20080213.txt
;
; $CmdLine[0] is number of parameters
; $CmdLine[1] is param 1 (after the script name)
; $CmdLine[2] is param 2 etc


$key = $CmdLine[1]
$encryptFile = $CmdLine[2]
$command = 'gpg --yes --batch --recipient "'&$key&'" -e '&$encryptFile

;MsgBox(0, "Running this...", $command)

RunWait(@ComSpec & " /c " & "$command")
Edited by laidback01
Link to comment
Share on other sites

Nevermind, I got it done super easily in a batch file. Guess I just don't know how to do this properly in autoit.

for those who might want to know...

::
:: File to run GPG with two command line args.
:: Argument 1 is the NAME of the key, Argument 2 is the file to be encrypted
:: Example: gpg.bat info@aai-office.com test_2008.txt
::
::
:: Program: C:\Program Files\GNU\GnuPG\gpg.exe 

"C:\Program Files\GNU\GnuPG\gpg.exe" --yes --batch --recipient %1 -e %2
Edited by laidback01
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...