Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I return an exit code from a VBScript console application

Tags:

vbscript

I Have an old vbs script file being kicked off by an AutoSys job. Can I, and how do I, return an int return value to indicate success or failure?

like image 305
Philip.ie Avatar asked Oct 09 '08 12:10

Philip.ie


People also ask

How do I end a VBScript statement?

A Exit For Statement is used when we want to Exit the For Loop based on certain criteria. When Exit For is executed, the control jumps to next statement immediately after the For Loop.

How do you handle errors in VBScript?

By checking the properties of the Err object after a particular piece of code has executed, you can determine whether an error has occurred and, if so, which one. You can then decide what to do about the error —you can, for instance, continue execution regardless of the error, or you can halt execution of the program.


2 Answers

Try:

WScript.Quit n

Where n is the ERRORLEVEL you want to return

like image 91
Rob Avatar answered Oct 06 '22 10:10

Rob


I found the answer :0)

 DIM returnValue
 returnValue = 99
 WScript.Quit(returnValue)

This seems to work well.

like image 38
Philip.ie Avatar answered Oct 06 '22 09:10

Philip.ie