none
Error handling in vbscript RRS feed

  • Question

  • 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?

        if Err.Description = "*Access Denied*" then
        WScript.Echo strServer & " Access Denied"
        Err.Clear
        end if

    thanks



    Thursday, August 20, 2015 3:04 PM

Answers

  • 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".


    -- Bill Stewart [Bill_Stewart]

    Thursday, August 20, 2015 3:18 PM
    Moderator

All replies

  • 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".


    -- Bill Stewart [Bill_Stewart]

    Thursday, August 20, 2015 3:18 PM
    Moderator
  • If Err.Number = &H80070005 Then

    There are no wild cards in VBScript.

    A better method is this:

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

    This way you won't miss errors.


    \_(ツ)_/



    • Edited by jrv Thursday, August 20, 2015 3:33 PM
    Thursday, August 20, 2015 3:32 PM
  • Also what do <> mean?

    <> is the inequality comparison test operator.

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


    Thursday, August 20, 2015 3:44 PM