.Quit - VBScript


The .Quit command in VB Script enables the graceful termination of a script. This command is a commonly used and effective way to end script execution and handle any necessary cleanup or finalization tasks.


.Quit [errorCode]


| Option | Description |
| errorCode | (Optional) Specifies an exit code to return when the script terminates. The default value is 0, indicating a successful execution. |


Simple Usage


This simple script terminates execution and returns an exit code of 0.

Custom Exit Code

.Quit 10

In this example, the script terminates and returns an exit code of 10.

Common Issues

No Cleanup Performed

If any cleanup or finalization tasks need to be performed before the script terminates, it is crucial to include the necessary code before the .Quit command.


The .Quit command can be used in conjunction with other VB Script commands for advanced script termination scenarios. For instance, it can be combined with error handling to provide graceful termination upon errors.

  • .End: Terminates the script immediately, without any cleanup or error handling.
  • .Close: Closes open files or connections, but does not terminate the script.