Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Return code

Reply
 
Old 09-19-2008   #1 (permalink)
Mario - Roma


 
 

Return code

I need to terminate a script and provide a return code to the calling
application.
The return code can be either TRUE of FALSE
I found different syntaxes in different places but none works for me
Can anybody please provide a sample of a right syntax?
The calling application supports either .exe and "script" files: should I
call my vbscript file directly or should I write something like "cscript //B
myfile.vbs"?
Regards
Marius




My System SpecsSystem Spec
Old 09-19-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: Return code


"Mario - Roma" <mario@xxxxxx> wrote in message
news:%23IKWRhlGJHA.3576@xxxxxx
Quote:

>I need to terminate a script and provide a return code to the calling
>application.
> The return code can be either TRUE of FALSE
> I found different syntaxes in different places but none works for me
> Can anybody please provide a sample of a right syntax?
> The calling application supports either .exe and "script" files: should I
> call my vbscript file directly or should I write something like "cscript
> //B myfile.vbs"?
> Regards
> Marius
You can terminate your VB Script program like so:
wscript.quit(x)
where x is the desired return code (an integer) that is then reflected by
the %ErrorLevel%.

In a robust environment you should invoke your scripts like so:
cscript //b //nologo c:\scripts\myfile.vbs
so that you don't need to rely on assocations. Remember to include drive +
folder for your script file!


My System SpecsSystem Spec
Old 09-19-2008   #3 (permalink)
Tom Lavedas


 
 

Re: Return code

On Sep 19, 9:04*am, "Mario - Roma" <ma...@xxxxxx> wrote:
Quote:

> I need to terminate a script and provide a return code to the calling
> application.
> The return code can be either TRUE of FALSE
> I found different syntax in different places but none works for me
> Can anybody please provide a sample of a right syntax?
> The calling application supports either .exe and "script" files: should I
> call my vbscript file directly or should I write something like "cscript //B
> myfile.vbs"?
> Regards
> Marius
I would suggest you call your script via cscript to insure it executes
correctly. The other approach relies on the correct file association
being set, which presents a small risk that the association is not
set.

The way to get a True/False return code is ...

wsh.quit True

or

wsh.quit False

as the last line of code executed in your script's code.

This is not declared as valid in the documentation, but since these
boolean arguments are actually stored as -1 and 0 for True and False,
respectively, it will work. Your calling code will need to process
them in an identical manner.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Windows Update for Vista KB946041 return error code 800736B2 Vista installation & setup
FTP return code VB Script
Live Messenger ignore Win32 API ReadFile return code and 100% CPU Live Messenger
COM+ Event System detected a bad return code Vista General
ATI Radeon Drivers - Code 43, Code 37 & Code 10 Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46