VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   Existing Script from Within Function (

krypton179 04-26-2019 10:37 AM

Existing Script from Within Function
Hi Experts,

I am looking for some further details of how I can exit an active script from within a function without logging the script path and line number.

Looking at earlier threads I found this logic, which works:

def CancelScript()

However, instead of opening a dialog box, I would like to exit the script without printing anything to the screen.

I looked into using the crt.Quit() option, but this closes CRT completely.

Are there any alternatives which I can use to accomplish this?

Kind Regards,


jpellegrini 04-26-2019 11:44 AM

Hi krypton179,

Unfortunately, there is currently not a way to disable the "Script Cancelled" dialog when a script is cancelled.

However, I have added this thread to a feature request in our product enhancement database for an option to disable the "Script Cancelled" dialog. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to and include "Feature Request - Forum Thread #13517" in the subject line or use this form from the support page of our website.

gregg 06-07-2019 12:57 PM

use try/except
sys.exit(0) causes an error, but you can raise an Exception to abort a function up to a try/except block and then do nothing with the exception.



# $language = "Python"
# $interface = "1.0"

# By having a specific exception to look for,
# other exceptions won't be ignored.
class EarlyExit(Exception):

def func2():
    crt.Dialog.MessageBox("About to exit script early", "Bye")
    raise EarlyExit()

def func1():

def main():
        crt.Dialog.MessageBox("Should not see this", "Wut")
    except EarlyExit:


All times are GMT -6. The time now is 03:16 AM.