Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell Question 1

Status
Not open for further replies.

AlexCuse

Programmer
Apr 13, 2006
5,416
US
Hi All,

I have written a couple of functions to utilize pgp command line encryption software. I was trying to add error handling to these functions, but I am running into trouble. I think I may be misunderstanding the Shell.

Here is the string I am sending to shell:
Code:
pgpDeStr = "pgp --decrypt " & InputFile & " --symmetric-passphrase SomePassphrase --output " & OutputFile

This runs just fine if I use
Code:
Call Shell(pgpDeStr)

However, when I try to capture the return value
Code:
retval = Shell(pgpDeStr)
It does not run at all. I was expecting it to return 0 if successful, and some non-zero error code if not.

For the meantime, I have added error handling based on a brief wait followed by checking for the existence of the output file, but I would like to be able to capture error codes returned by pgp.

If anyone has advice on what I'm doing wrong I'd be very grateful.

Thanks for reading,

Alex


Ignorance of certain subjects is a great part of wisdom
 
The Shell functions returns a task ID (as clearly explained in the VBA help ...)
You may try this:
Set WshShell = CreateObject("WScript.Shell")
pgpDeStr = "pgp --decrypt """ & InputFile & """ --symmetric-passphrase SomePassphrase --output """ & OutputFile & """"
retval = WshShell.Run(pgpDeStr, 1, True)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH - I saw that yesterday just after I posted. I remembered returning a value from the shell in an older process, but apparently I mixed things up (just revisited old process [blush] )

This does look like what I need though. I will test it out right now and let you know how it worked in a few.

Thanks, as usual!

Ignorance of certain subjects is a great part of wisdom
 
Well, this does not seem to be capturing the return value correctly either. It is unable to wait for process completion, and if I set the wait parameter to false it does not decrypt (it just opens a folder containing my pgp keyrings). This is confusing the heck out of me, as I can see the code returned when I type my string in the dos window.

So for now, I guess my error handling is going to continue to be based on output file existence. I suppose it could be worse (at least it is my boss, not me, who will need to wake up at 4:30 am if this thing fails).

Thanks anyway PH, Have a purple thingy.

Alex

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top