Hi Guys,

Yes I am trying to use pgp command line.

The script below adds new keys to a users public key ring (pkr)

code:
$pgp_prefs = "%userprofile%\application data\network associates\pgp\pgpprefs.txt"

IF OPEN(2,$pgp_prefs) <> 0
COLOR r+/b
? " - Error opening PGPprefs.txt"
COLOR w+/b
RETURN
ENDIF

DO
$x = READLINE(2)
UNTIL INSTR($x, "UserAccountStatus") OR @ERROR = -1

SELECT
CASE $x = "UserAccountStatus=0"
? " - PGP is running for the first time. The key generation wizard will display."
CLOSE(2)
RETURN

CASE $x = "UserAccountStatus=1"
? " - PGP is installed but the current user is not configured to use it."
CLOSE(2)
RETURN

CASE $x = "UserAccountStatus=2"
;? " - PGP is installed and the current user is configured to use it"
? " - Updating PGP public keyring ... "

$pgp_exe = FindProfileSectionData($pgp, "pgp_exe")
IF $error = 1
RETURN
ENDIF

$pgp_keys = FindProfileSectionData($pgp, "pgp_keys")
IF $error = 1
RETURN
ENDIF

DO
$x = READLINE(2)
UNTIL INSTR($x, "PublicKeyringFile") OR @ERROR = -1

$pos = INSTR($x, CHR(61)) + 1
$len = LEN($x)
$pkr_len = $len - $pos + 1
$pgp_pkr = substr ($x, $pos, $pkr_len)

? shell "%comspec% /c" + $pgp_exe + " -ka +batchmode +pubring=" + $pgp_pkr + " " + $pgp_keys

IF @ERROR = 0
? "Update completed"
ELSE
COLOR r+/b
? " - Error updating PGP public keyring"
COLOR w+/b
ENDIF
ENDSELECT
CLOSE(2)


The script works great. The only problem is that it displays a load of text when pgp.exe runs.

FYI :- FindProfileSectionData is a udf i've written. It reads in entries from a config file.

The -q doesn't seem to work, piping it also doesn't work. Any ideas?

Tim.

[ 05 February 2002: Message edited by: t_pickering ]

[ 05 February 2002: Message edited by: t_pickering ]