Some (most) apps set error codes that can be used in a script. It all depends on how the external app returns the error codes and how it wants the parameters (-parameter, /parameter, \parameter, etc...) some extra info would be nice.

The error code can be taken from @error, the username can be taken from @userid, logoff if error can be done by LogOff() and the external app (and let the script wait until the app exits) can be done by Shell.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.