Page 1 of 1

Maybe a silly question but ...

PostPosted: Sun Mar 01, 2009 8:52 am
by cp4w
I am trying to exit a vbs script early if an error is detected using Wscript.Quit but it does not work. the error I get is
"object required wscript"

If I use
WScript.Echo "xxx" I get an error
type mismatch for echo

But Wscript is available because this does work
Set WSHShell = CreateObject("WScript.Shell")

What is going on?

PostPosted: Mon Mar 02, 2009 11:53 am
by Neosoft Support
Thanks to Microsoft, this is pretty confusing, but the website below takes a stab at explaining why you can't use WScript:

http://www.microsoft.com/technet/scriptcenter/funzone/puzzle/answers/jul2106.mspx

PostPosted: Mon Mar 02, 2009 12:21 pm
by cp4w
Thanks for the reply.

My problem now is how can we leave the script (early termination)when an error condition occurs.
I don't think "exit" works, the only way I know is "Wscript.Quit" but that also doesn't work as the link you supplied would indicate.

PostPosted: Mon Mar 02, 2009 12:46 pm
by Gaev
Steven:

If you post your current vbscript (with the non performing quit command) ... perhaps it can be restructured so ... under certain circumstances it drops to the physical end of the script ... where it will be terminated.

PostPosted: Mon Mar 02, 2009 2:30 pm
by cp4w
Gaev, thanks for the offer. But I am not focusing on a particular script rather looking to understand what is available in coding these scripts.

PostPosted: Mon Mar 02, 2009 4:24 pm
by Neosoft Support
Here's a link to Microsoft's VBScript User's Guide:

http://msdn.microsoft.com/en-us/library/t0aew7h6(VS.85).aspx

PostPosted: Mon Mar 02, 2009 4:32 pm
by cp4w
thanks,
There is an exit sub command and I think that everything is suppose to be a sub routine.