Decrypting pgp files with vbscript
I'm trying to decrypt a gnupgp file using a vbscript. Here a copy of my script...
1) I created a WScript object, on which I execute the gpg command with the --decrypt function. Even though I can successfully decrypt the file I can't seem to automate the part where I have to provide my passphrase.
Has anyone dealt with this? If so I'd appreciate any help.
thanks,
--------------------------------------------------------
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder("C:\Inetpub\ftproot\ConcurrFTP\Inbox ")
Set objFiles = objFolder.Files
Dim oShell
Set oShell = WScript.CreateObject ("WScript.shell")
fPath = "C:\Inetpub\ftproot\ConcurrFTP\Inbox\"
dteCurrent = Date()
timCurrent = Time()
dteDay = Day(dteCurrent)
dteMonth = Month(dteCurrent)
dteYear = Year(dteCurrent)
timMin = Minute(timCurrent)
timHou = Hour(timCurrent)
if dteMonth < 10 then dteMonth = "0" & dteMonth
if dteDay < 10 then dteDay = "0" & dteDay
Set f1 = fso.CreateTextFile(fPath & fFile, True)
' step through the files collection
For Each objFile in objFiles
' get a file's name
strName = objFile.Name
' make it lowercase for the URL
strFile = Lcase(strName)
' get the file's type
strType = objFile.Type
' make the name a title for display
'strName = MakeTitle(strName)
' get the file size in KB
'lngSize = objFile.Size\1024
NewFName = strFile
NewFNameLen = len(NewFname)
NewFName = Left(NewFName,NewFNameLen-4) & ".txt"
gnuComm = objFile
FilTyp = left(strFile,4)
CurDat = dteYear & dteMonth & dteDay
CurrentDate = ""
ActualDate = ""
if FilTyp = "extr" then
ActDate = mid(strFile,16,8)
CurrentDate = CurDat
ActualDate = ActDate
if CurrentDate = ActualDate then
'Decrypt file
gnuComm2 = "c:\gnupg\gpg -o " & FPath & NewFName " --passphrase-fd 0 -d " & objFile
gnuComm = gnuComm2
oShell.Run gnuComm, 1, true
end if
end if
Next
|