Public Class Main Friend Shared returnCode As Integer = 0 Public Shared Function Main() As Integer ' Start processing here Return returnCode End Function End ClassThe processing is wrapped in Try... Catch so, in case of the error the error handling code sets returnCode variable to appropriate value in addition to saving the related error info into the log file. The external scheduler application can read the return value from OS ERRORLEVEL variable.