How to generate exit code using vbscript other that wscript.quit ?
How to generate exit code using vbscript other that wscript.quit ?
I have 3 part in a single vbscript and for each part , i have to generate exit code. So Please help.
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
flip1001
10 years ago
Posted by:
p.d.das
10 years ago
if i use wscript.quit (1), it will stop , will not execute the code after that.
Comments:
-
Golly! You told the script engine to quit and none of the code after that statement got executed. Imagine that! - anonymous_9363 10 years ago
-
Are you serious? To generate an EXIT code, your application has to EXIT. One of the notable features of code execution is that it STOPS when you EXIT!
You really need to think carefully about what you need your code to do before posting truly bizarre comments about your expectations....<g> - EdT 10 years ago
Posted by:
Jimadine
9 years ago
Here's a contrived example of how you might do this.
1/ Copy and paste the example code into notepad and save to a file with a .vbs extension
2/ Open a Windows command prompt.
3/ Change directory (cd) to the path containing the .vbs file
4/ Type cscript //nologo file.vbs
Example code:
To check the error level type echo %ERRORLEVEL%<CR>. Edit and save the myName variable value in the vbs file and observe the change in exit code after typing echo %ERRORLEVEL%<CR>.
1/ Copy and paste the example code into notepad and save to a file with a .vbs extension
2/ Open a Windows command prompt.
3/ Change directory (cd) to the path containing the .vbs file
4/ Type cscript //nologo file.vbs
Example code:
Option Explicit
Dim myName, myExitCode
myName = "Bob"
Select Case myName
Case "Bob"
myExitCode = 1
Case "Sara"
myExitCode = 1
Case "Charles"
myExitCode = 0
End Select
WScript.Quit myExitCode
To check the error level type echo %ERRORLEVEL%<CR>. Edit and save the myName variable value in the vbs file and observe the change in exit code after typing echo %ERRORLEVEL%<CR>.