Sign in to follow this  
Followers 0
benjbong

running pgp from command line works, but not from autoit script

5 posts in this topic

#1 ·  Posted (edited)

I have PGP command line 6.5.8 installed and i'm trying to run a pgp decrypt command from a script. The command is:

pgp filetodecrypt.pgp outputfile.txt -z password

If i run this from the command prompt it runs just fine and successfully decrypts the file. If i try to run it from an autoitscript the command prompt will flash and the script will close without decrypting the file, but a screen capture shows this error:

"File is encrypted. Secret key is required to read it.

You do not have the secret key needed to decrypt this file."

I've tried using runas to run as the local administrator, tried running from @comspec, and tried outputting the command to a batchfile and running the batch file but all with the same result. So what is going on that i can run it directly from the command line but it fails from the script?

Here's the script:

#include <File.au3>
DecryptFiles("D:Payerspgpconvert")
func DecryptFiles($decryptPath)
   $List = _FileListToArray($decryptPath, "*.pgp", 1)
   If @error = 4 Then
        msgbox(0, "", "No .pgp files found")
   ElseIf @error = 0 Then
        For $x = 1 to ubound($List) -1 step 1
             $decryptedName = StringTrimRight($List[$x], 4)
             RunWait("pgp -z password " & $decryptPath & $List[$x] & " " & $decryptPath & $decryptedName)
             FileDelete($decryptPath & $List[$x])
        Next
   EndIf
EndFunc
Edited by benjbong

Share this post


Link to post
Share on other sites



Run(@ComSpec & " /c " & '"pgp -z password " & $decryptPath & $List[$x] & " " & $decryptPath & $decryptedName', "", @SW_HIDE)


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Run(@ComSpec & " /c " & '"pgp -z password " & $decryptPath & $List[$x] & " " & $decryptPath & $decryptedName', "", @SW_HIDE)

no change

Share this post


Link to post
Share on other sites

Try this version and change the /k to /c when it works.

Run(@ComSpec & " /k " & "pgp -z password " & $decryptPath & $List[$x] & " " & $decryptPath & $decryptedName)

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks for the suggestions. I got it working - for anybody who might have issues with this program in the future (unlikely) i had to do a few things:

1. manually set the system variable PGPPATH=C:Program FilesNetwork AssociatesPGPcmdln through the system properties GUI, not the set command on the command line. For some reason the set command wasn't working properly.

2. change the trust on the private keys if they were imported from another server through pgp -ke then set the trust level to 4

3. Add C:Program FilesNetwork AssociatesPGPcmdln to the system path

Once everything was set right i was able to run the command using run("pgp ...")

Share this post


Link to post
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
Sign in to follow this  
Followers 0