Error handling in vbscript

Hi, i have a vbscript and i want to catch certain description. I am not sure about the syntax in vbscript, in powershell you could use wild cards, is there something similar in vbscript that i could use? Trying to do something like this. Also what do <> mean?

ifErr.Description="*AccessDenied*"then
WScript.EchostrServer&"AccessDenied"
Err.Clear
    end if

thanks



August 20th, 2015 11:08am

If want to learn VBScript, I would suggest starting at the beginning:

VBScript Language Reference

(Hint: I found this link by typing the search phrase 'vbscript documentation' in a search engine.)

To search for strings inside other strings, you can use the InStr function. VBScript doesn't have a "like" operator that supports wildcards in strings like PowerShell does.

We'd recommend learning PowerShell instead of VBScript.

Per your second question: Are you asking about the < and > operators? Look in the documentation under "comparison operators".

Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 11:22am

If Err.Number = &H80070005 Then

There are no wild cards in VBScript.

A better method is this:

ifErr.Number <> 0then WScript.EchoErr.Description
WScript.Quit Err.Number end if

This way you won't miss errors.

August 20th, 2015 11:35am

Also what do <> mean?

<> is the inequality comparison test operator.

http://ss64.com/vb/syntax-operators.html

Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 11:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics