Announcement

Collapse
No announcement yet.

On Error Resume Next not working on GetObject WMI

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • On Error Resume Next not working on GetObject WMI

    I have a script with the following code block:
    Code:
    ...
    Err.Clear
    On Error Resume Next
    Set objWMIService = GetObject("winmgmts:\\" & strServer & "\root\CIMV2")
    If Err.Number Then
        <QUIT GRACEFULLY>
    End If
    ...
    However, when I run it where strServer = nonExistantMachine I get a complete lack of error handling:
    Code:
    (290, 14) Microsoft VBScript runtime error: The remote server machine does not exist or is unavailable
    Why is this occurring if I have told it to continue on error so that I can handle it myself?

  • #2
    Re: On Error Resume Next not working on GetObject WMI

    can you show what is on line 290?

    Is this a line in a subroutine or in a function?
    The 'On Error Resume Next' is not Global, you have to write it in every sub.

    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X