Ping Function for vb2003

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Marden

    Ping Function for vb2003

    I currently use this routine in vbscript to ping computers and get the
    status of ping to determine whether to try to backup a machine, I am trying
    to change it to work with vb2003.net I am wondering if anyone has a ping
    function they could share with me.

    I have done some searching on this but cannot find anything specifically for
    vb2003.

    Sub PingComputer
    If PingStatus(PCNa me) = "Success" Then
    RunBackup
    End If
    End Sub

    Function PingStatus(strW orkStation)
    Set objWMIService = GetObject("winm gmts:" _
    & "{impersonation Level=impersona te}!\\" & strWorkStation & "\root\cimv 2")
    Set colPings = objWMIService.E xecQuery _
    ("SELECT * FROM Win32_PingStatu s WHERE Address = '" & MachineInfo(0) &
    "'")
    For Each objPing in colPings
    Select Case objPing.StatusC ode
    Case 0 PingStatus = "Success"
    Case 11001 PingStatus = "Ping UnSuccessful -- Buffer Too Small"
    Case 11002 PingStatus = "Ping UnSuccessful -- Destination Net
    Unreachable"
    Case 11003 PingStatus = "Ping UnSuccessful -- Destination Host
    Unreachable"
    Case 11004 PingStatus = "Ping UnSuccessful -- Destination Protocol
    Unreachable"
    Case 11005 PingStatus = "Ping UnSuccessful -- Destination Port
    Unreachable"
    Case 11006 PingStatus = "Ping UnSuccessful -- No Resources"
    Case 11007 PingStatus = "Ping UnSuccessful -- Bad Option"
    Case 11008 PingStatus = "Ping UnSuccessful -- Hardware Error"
    Case 11009 PingStatus = "Ping UnSuccessful -- Packet Too Big"
    Case 11010 PingStatus = "Ping UnSuccessful -- Request Timed Out"
    Case 11011 PingStatus = "Ping UnSuccessful -- Bad Request"
    Case 11012 PingStatus = "Ping UnSuccessful -- Bad Route"
    Case 11013 PingStatus = "Ping UnSuccessful -- TimeToLive Expired Transit"
    Case 11014 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
    Reassembly"
    Case 11015 PingStatus = "Ping UnSuccessful -- Parameter Problem"
    Case 11016 PingStatus = "Ping UnSuccessful -- Source Quench"
    Case 11017 PingStatus = "Ping UnSuccessful -- Option Too Big"
    Case 11018 PingStatus = "Ping UnSuccessful -- Bad Destination"
    Case 11032 PingStatus = "Ping UnSuccessful -- Negotiating IPSEC"
    Case 11050 PingStatus = "Ping UnSuccessful -- General Failure"
    Case Else PingStatus = "Ping UnSuccessful -- Unable to determine cause of
    failure."
    End Select
    Next
    End Function

    Thanks In Advance,
    Dave Marden


  • Phillip Taylor

    #2
    Re: Ping Function for vb2003

    On 3 Sep, 17:38, "Dave Marden" <newsgr...@mard enfamily.comwro te:
    I currently use this routine in vbscript to ping computers and get the
    status of ping to determine whether to try to backup a machine, I am trying
    to change it to work with vb2003.net I am wondering if anyone has a ping
    function they could share with me.
    >
    I have done some searching on this but cannot find anything specifically for
    vb2003.
    >
    Sub PingComputer
    If PingStatus(PCNa me) = "Success" Then
    RunBackup
    End If
    End Sub
    >
    Function PingStatus(strW orkStation)
    Set objWMIService = GetObject("winm gmts:" _
    & "{impersonation Level=impersona te}!\\" & strWorkStation & "\root\cimv 2")
    Set colPings = objWMIService.E xecQuery _
    ("SELECT * FROM Win32_PingStatu s WHERE Address = '" & MachineInfo(0) &
    "'")
    For Each objPing in colPings
    Select Case objPing.StatusC ode
    Case 0 PingStatus = "Success"
    Case 11001 PingStatus = "Ping UnSuccessful -- Buffer Too Small"
    Case 11002 PingStatus = "Ping UnSuccessful -- Destination Net
    Unreachable"
    Case 11003 PingStatus = "Ping UnSuccessful -- Destination Host
    Unreachable"
    Case 11004 PingStatus = "Ping UnSuccessful -- Destination Protocol
    Unreachable"
    Case 11005 PingStatus = "Ping UnSuccessful -- Destination Port
    Unreachable"
    Case 11006 PingStatus = "Ping UnSuccessful -- No Resources"
    Case 11007 PingStatus = "Ping UnSuccessful -- Bad Option"
    Case 11008 PingStatus = "Ping UnSuccessful -- Hardware Error"
    Case 11009 PingStatus = "Ping UnSuccessful -- Packet Too Big"
    Case 11010 PingStatus = "Ping UnSuccessful -- Request Timed Out"
    Case 11011 PingStatus = "Ping UnSuccessful -- Bad Request"
    Case 11012 PingStatus = "Ping UnSuccessful -- Bad Route"
    Case 11013 PingStatus = "Ping UnSuccessful -- TimeToLive Expired Transit"
    Case 11014 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
    Reassembly"
    Case 11015 PingStatus = "Ping UnSuccessful -- Parameter Problem"
    Case 11016 PingStatus = "Ping UnSuccessful -- Source Quench"
    Case 11017 PingStatus = "Ping UnSuccessful -- Option Too Big"
    Case 11018 PingStatus = "Ping UnSuccessful -- Bad Destination"
    Case 11032 PingStatus = "Ping UnSuccessful -- Negotiating IPSEC"
    Case 11050 PingStatus = "Ping UnSuccessful -- General Failure"
    Case Else PingStatus = "Ping UnSuccessful -- Unable to determine cause of
    failure."
    End Select
    Next
    End Function
    >
    Thanks In Advance,
    Dave Marden
    Try this:

    My.Computer.Net work.Ping("127. 0.0.1")

    returns a boolean true or false.

    Hope it helps,

    Phillip Ross Taylor

    Comment

    • Dave Marden

      #3
      Re: Ping Function for vb2003

      I thought that the "MY" keyword was only available in vb2005?

      Dave

      "Phillip Taylor" <Phillip.Ross.T aylor@gmail.com wrote in message
      news:1188839442 .530959.137910@ 22g2000hsm.goog legroups.com...
      On 3 Sep, 17:38, "Dave Marden" <newsgr...@mard enfamily.comwro te:
      >I currently use this routine in vbscript to ping computers and get the
      >status of ping to determine whether to try to backup a machine, I am
      >trying
      >to change it to work with vb2003.net I am wondering if anyone has a ping
      >function they could share with me.
      >>
      >I have done some searching on this but cannot find anything specifically
      >for
      >vb2003.
      >>
      >Sub PingComputer
      > If PingStatus(PCNa me) = "Success" Then
      > RunBackup
      > End If
      >End Sub
      >>
      >Function PingStatus(strW orkStation)
      > Set objWMIService = GetObject("winm gmts:" _
      > & "{impersonation Level=impersona te}!\\" & strWorkStation &
      >"\root\cimv2 ")
      > Set colPings = objWMIService.E xecQuery _
      > ("SELECT * FROM Win32_PingStatu s WHERE Address = '" & MachineInfo(0) &
      >"'")
      > For Each objPing in colPings
      > Select Case objPing.StatusC ode
      > Case 0 PingStatus = "Success"
      > Case 11001 PingStatus = "Ping UnSuccessful -- Buffer Too Small"
      > Case 11002 PingStatus = "Ping UnSuccessful -- Destination Net
      >Unreachable"
      > Case 11003 PingStatus = "Ping UnSuccessful -- Destination Host
      >Unreachable"
      > Case 11004 PingStatus = "Ping UnSuccessful -- Destination Protocol
      >Unreachable"
      > Case 11005 PingStatus = "Ping UnSuccessful -- Destination Port
      >Unreachable"
      > Case 11006 PingStatus = "Ping UnSuccessful -- No Resources"
      > Case 11007 PingStatus = "Ping UnSuccessful -- Bad Option"
      > Case 11008 PingStatus = "Ping UnSuccessful -- Hardware Error"
      > Case 11009 PingStatus = "Ping UnSuccessful -- Packet Too Big"
      > Case 11010 PingStatus = "Ping UnSuccessful -- Request Timed Out"
      > Case 11011 PingStatus = "Ping UnSuccessful -- Bad Request"
      > Case 11012 PingStatus = "Ping UnSuccessful -- Bad Route"
      > Case 11013 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
      >Transit"
      > Case 11014 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
      >Reassembly"
      > Case 11015 PingStatus = "Ping UnSuccessful -- Parameter Problem"
      > Case 11016 PingStatus = "Ping UnSuccessful -- Source Quench"
      > Case 11017 PingStatus = "Ping UnSuccessful -- Option Too Big"
      > Case 11018 PingStatus = "Ping UnSuccessful -- Bad Destination"
      > Case 11032 PingStatus = "Ping UnSuccessful -- Negotiating IPSEC"
      > Case 11050 PingStatus = "Ping UnSuccessful -- General Failure"
      > Case Else PingStatus = "Ping UnSuccessful -- Unable to determine cause
      >of
      >failure."
      > End Select
      > Next
      >End Function
      >>
      >Thanks In Advance,
      >Dave Marden
      >
      Try this:
      >
      My.Computer.Net work.Ping("127. 0.0.1")
      >
      returns a boolean true or false.
      >
      Hope it helps,
      >
      Phillip Ross Taylor
      >

      Comment

      • Dave Marden

        #4
        Re: Ping Function for vb2003

        Another Thing, I would like to be able to keep the functionality of using it
        also as a troubleshooting function, ultimately if the ping fails I am
        letting the user know why.

        Dave


        "Phillip Taylor" <Phillip.Ross.T aylor@gmail.com wrote in message
        news:1188839442 .530959.137910@ 22g2000hsm.goog legroups.com...
        On 3 Sep, 17:38, "Dave Marden" <newsgr...@mard enfamily.comwro te:
        >I currently use this routine in vbscript to ping computers and get the
        >status of ping to determine whether to try to backup a machine, I am
        >trying
        >to change it to work with vb2003.net I am wondering if anyone has a ping
        >function they could share with me.
        >>
        >I have done some searching on this but cannot find anything specifically
        >for
        >vb2003.
        >>
        >Sub PingComputer
        > If PingStatus(PCNa me) = "Success" Then
        > RunBackup
        > End If
        >End Sub
        >>
        >Function PingStatus(strW orkStation)
        > Set objWMIService = GetObject("winm gmts:" _
        > & "{impersonation Level=impersona te}!\\" & strWorkStation &
        >"\root\cimv2 ")
        > Set colPings = objWMIService.E xecQuery _
        > ("SELECT * FROM Win32_PingStatu s WHERE Address = '" & MachineInfo(0) &
        >"'")
        > For Each objPing in colPings
        > Select Case objPing.StatusC ode
        > Case 0 PingStatus = "Success"
        > Case 11001 PingStatus = "Ping UnSuccessful -- Buffer Too Small"
        > Case 11002 PingStatus = "Ping UnSuccessful -- Destination Net
        >Unreachable"
        > Case 11003 PingStatus = "Ping UnSuccessful -- Destination Host
        >Unreachable"
        > Case 11004 PingStatus = "Ping UnSuccessful -- Destination Protocol
        >Unreachable"
        > Case 11005 PingStatus = "Ping UnSuccessful -- Destination Port
        >Unreachable"
        > Case 11006 PingStatus = "Ping UnSuccessful -- No Resources"
        > Case 11007 PingStatus = "Ping UnSuccessful -- Bad Option"
        > Case 11008 PingStatus = "Ping UnSuccessful -- Hardware Error"
        > Case 11009 PingStatus = "Ping UnSuccessful -- Packet Too Big"
        > Case 11010 PingStatus = "Ping UnSuccessful -- Request Timed Out"
        > Case 11011 PingStatus = "Ping UnSuccessful -- Bad Request"
        > Case 11012 PingStatus = "Ping UnSuccessful -- Bad Route"
        > Case 11013 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
        >Transit"
        > Case 11014 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
        >Reassembly"
        > Case 11015 PingStatus = "Ping UnSuccessful -- Parameter Problem"
        > Case 11016 PingStatus = "Ping UnSuccessful -- Source Quench"
        > Case 11017 PingStatus = "Ping UnSuccessful -- Option Too Big"
        > Case 11018 PingStatus = "Ping UnSuccessful -- Bad Destination"
        > Case 11032 PingStatus = "Ping UnSuccessful -- Negotiating IPSEC"
        > Case 11050 PingStatus = "Ping UnSuccessful -- General Failure"
        > Case Else PingStatus = "Ping UnSuccessful -- Unable to determine cause
        >of
        >failure."
        > End Select
        > Next
        >End Function
        >>
        >Thanks In Advance,
        >Dave Marden
        >
        Try this:
        >
        My.Computer.Net work.Ping("127. 0.0.1")
        >
        returns a boolean true or false.
        >
        Hope it helps,
        >
        Phillip Ross Taylor
        >

        Comment

        • Cor Ligthert[MVP]

          #5
          Re: Ping Function for vb2003

          Dave,

          Probably it is in 2005 because there is so many often asked for it in when
          2003 was the latest version. However you can do use the application.run to
          do it in a kind of workaround.

          The sample is not in it, however can go in the same way as this.



          Cor

          "Dave Marden" <newsgroup@mard enfamily.comsch reef in bericht
          news:Onb9n6k7HH A.4660@TK2MSFTN GP02.phx.gbl...
          >I thought that the "MY" keyword was only available in vb2005?
          >
          Dave
          >
          "Phillip Taylor" <Phillip.Ross.T aylor@gmail.com wrote in message
          news:1188839442 .530959.137910@ 22g2000hsm.goog legroups.com...
          >On 3 Sep, 17:38, "Dave Marden" <newsgr...@mard enfamily.comwro te:
          >>I currently use this routine in vbscript to ping computers and get the
          >>status of ping to determine whether to try to backup a machine, I am
          >>trying
          >>to change it to work with vb2003.net I am wondering if anyone has a ping
          >>function they could share with me.
          >>>
          >>I have done some searching on this but cannot find anything specifically
          >>for
          >>vb2003.
          >>>
          >>Sub PingComputer
          >> If PingStatus(PCNa me) = "Success" Then
          >> RunBackup
          >> End If
          >>End Sub
          >>>
          >>Function PingStatus(strW orkStation)
          >> Set objWMIService = GetObject("winm gmts:" _
          >> & "{impersonation Level=impersona te}!\\" & strWorkStation &
          >>"\root\cimv2" )
          >> Set colPings = objWMIService.E xecQuery _
          >> ("SELECT * FROM Win32_PingStatu s WHERE Address = '" & MachineInfo(0) &
          >>"'")
          >> For Each objPing in colPings
          >> Select Case objPing.StatusC ode
          >> Case 0 PingStatus = "Success"
          >> Case 11001 PingStatus = "Ping UnSuccessful -- Buffer Too Small"
          >> Case 11002 PingStatus = "Ping UnSuccessful -- Destination Net
          >>Unreachable "
          >> Case 11003 PingStatus = "Ping UnSuccessful -- Destination Host
          >>Unreachable "
          >> Case 11004 PingStatus = "Ping UnSuccessful -- Destination Protocol
          >>Unreachable "
          >> Case 11005 PingStatus = "Ping UnSuccessful -- Destination Port
          >>Unreachable "
          >> Case 11006 PingStatus = "Ping UnSuccessful -- No Resources"
          >> Case 11007 PingStatus = "Ping UnSuccessful -- Bad Option"
          >> Case 11008 PingStatus = "Ping UnSuccessful -- Hardware Error"
          >> Case 11009 PingStatus = "Ping UnSuccessful -- Packet Too Big"
          >> Case 11010 PingStatus = "Ping UnSuccessful -- Request Timed Out"
          >> Case 11011 PingStatus = "Ping UnSuccessful -- Bad Request"
          >> Case 11012 PingStatus = "Ping UnSuccessful -- Bad Route"
          >> Case 11013 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
          >>Transit"
          >> Case 11014 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
          >>Reassembly"
          >> Case 11015 PingStatus = "Ping UnSuccessful -- Parameter Problem"
          >> Case 11016 PingStatus = "Ping UnSuccessful -- Source Quench"
          >> Case 11017 PingStatus = "Ping UnSuccessful -- Option Too Big"
          >> Case 11018 PingStatus = "Ping UnSuccessful -- Bad Destination"
          >> Case 11032 PingStatus = "Ping UnSuccessful -- Negotiating IPSEC"
          >> Case 11050 PingStatus = "Ping UnSuccessful -- General Failure"
          >> Case Else PingStatus = "Ping UnSuccessful -- Unable to determine
          >>cause of
          >>failure."
          >> End Select
          >> Next
          >>End Function
          >>>
          >>Thanks In Advance,
          >>Dave Marden
          >>
          >Try this:
          >>
          >My.Computer.Ne twork.Ping("127 .0.0.1")
          >>
          >returns a boolean true or false.
          >>
          >Hope it helps,
          >>
          >Phillip Ross Taylor
          >>
          >
          >

          Comment

          • Cor Ligthert[MVP]

            #6
            Re: Ping Function for vb2003

            Dave,

            Probably it is in 2005 because there is so many often asked for it in when
            2003 was the latest version. However you can do use the application.run to
            do it in a kind of workaround.

            The sample is not in it, however can go in the same way as this.



            Cor


            "Dave Marden" <newsgroup@mard enfamily.comsch reef in bericht
            news:eQJvZik7HH A.2752@TK2MSFTN GP06.phx.gbl...
            >I currently use this routine in vbscript to ping computers and get the
            >status of ping to determine whether to try to backup a machine, I am trying
            >to change it to work with vb2003.net I am wondering if anyone has a ping
            >function they could share with me.
            >
            I have done some searching on this but cannot find anything specifically
            for vb2003.
            >
            Sub PingComputer
            If PingStatus(PCNa me) = "Success" Then
            RunBackup
            End If
            End Sub
            >
            Function PingStatus(strW orkStation)
            Set objWMIService = GetObject("winm gmts:" _
            & "{impersonation Level=impersona te}!\\" & strWorkStation & "\root\cimv 2")
            Set colPings = objWMIService.E xecQuery _
            ("SELECT * FROM Win32_PingStatu s WHERE Address = '" & MachineInfo(0) &
            "'")
            For Each objPing in colPings
            Select Case objPing.StatusC ode
            Case 0 PingStatus = "Success"
            Case 11001 PingStatus = "Ping UnSuccessful -- Buffer Too Small"
            Case 11002 PingStatus = "Ping UnSuccessful -- Destination Net
            Unreachable"
            Case 11003 PingStatus = "Ping UnSuccessful -- Destination Host
            Unreachable"
            Case 11004 PingStatus = "Ping UnSuccessful -- Destination Protocol
            Unreachable"
            Case 11005 PingStatus = "Ping UnSuccessful -- Destination Port
            Unreachable"
            Case 11006 PingStatus = "Ping UnSuccessful -- No Resources"
            Case 11007 PingStatus = "Ping UnSuccessful -- Bad Option"
            Case 11008 PingStatus = "Ping UnSuccessful -- Hardware Error"
            Case 11009 PingStatus = "Ping UnSuccessful -- Packet Too Big"
            Case 11010 PingStatus = "Ping UnSuccessful -- Request Timed Out"
            Case 11011 PingStatus = "Ping UnSuccessful -- Bad Request"
            Case 11012 PingStatus = "Ping UnSuccessful -- Bad Route"
            Case 11013 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
            Transit"
            Case 11014 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
            Reassembly"
            Case 11015 PingStatus = "Ping UnSuccessful -- Parameter Problem"
            Case 11016 PingStatus = "Ping UnSuccessful -- Source Quench"
            Case 11017 PingStatus = "Ping UnSuccessful -- Option Too Big"
            Case 11018 PingStatus = "Ping UnSuccessful -- Bad Destination"
            Case 11032 PingStatus = "Ping UnSuccessful -- Negotiating IPSEC"
            Case 11050 PingStatus = "Ping UnSuccessful -- General Failure"
            Case Else PingStatus = "Ping UnSuccessful -- Unable to determine cause
            of failure."
            End Select
            Next
            End Function
            >
            Thanks In Advance,
            Dave Marden
            >

            Comment

            • Dave Marden

              #7
              Re: Ping Function for vb2003

              Thanks Works excellent for what I am doing.

              Dave Marden


              "Cor Ligthert[MVP]" <notmyfirstname @planet.nlwrote in message
              news:706FAB2B-1F81-4C81-A0C1-F229533744BB@mi crosoft.com...
              Dave,
              >
              Probably it is in 2005 because there is so many often asked for it in when
              2003 was the latest version. However you can do use the application.run to
              do it in a kind of workaround.
              >
              The sample is not in it, however can go in the same way as this.
              >

              >
              Cor
              >
              >
              "Dave Marden" <newsgroup@mard enfamily.comsch reef in bericht
              news:eQJvZik7HH A.2752@TK2MSFTN GP06.phx.gbl...
              >>I currently use this routine in vbscript to ping computers and get the
              >>status of ping to determine whether to try to backup a machine, I am
              >>trying to change it to work with vb2003.net I am wondering if anyone has a
              >>ping function they could share with me.
              >>
              >I have done some searching on this but cannot find anything specifically
              >for vb2003.
              >>
              >Sub PingComputer
              >If PingStatus(PCNa me) = "Success" Then
              > RunBackup
              >End If
              >End Sub
              >>
              >Function PingStatus(strW orkStation)
              >Set objWMIService = GetObject("winm gmts:" _
              > & "{impersonation Level=impersona te}!\\" & strWorkStation &
              >"\root\cimv2 ")
              >Set colPings = objWMIService.E xecQuery _
              > ("SELECT * FROM Win32_PingStatu s WHERE Address = '" & MachineInfo(0) &
              >"'")
              >For Each objPing in colPings
              > Select Case objPing.StatusC ode
              > Case 0 PingStatus = "Success"
              > Case 11001 PingStatus = "Ping UnSuccessful -- Buffer Too Small"
              > Case 11002 PingStatus = "Ping UnSuccessful -- Destination Net
              >Unreachable"
              > Case 11003 PingStatus = "Ping UnSuccessful -- Destination Host
              >Unreachable"
              > Case 11004 PingStatus = "Ping UnSuccessful -- Destination Protocol
              >Unreachable"
              > Case 11005 PingStatus = "Ping UnSuccessful -- Destination Port
              >Unreachable"
              > Case 11006 PingStatus = "Ping UnSuccessful -- No Resources"
              > Case 11007 PingStatus = "Ping UnSuccessful -- Bad Option"
              > Case 11008 PingStatus = "Ping UnSuccessful -- Hardware Error"
              > Case 11009 PingStatus = "Ping UnSuccessful -- Packet Too Big"
              > Case 11010 PingStatus = "Ping UnSuccessful -- Request Timed Out"
              > Case 11011 PingStatus = "Ping UnSuccessful -- Bad Request"
              > Case 11012 PingStatus = "Ping UnSuccessful -- Bad Route"
              > Case 11013 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
              >Transit"
              > Case 11014 PingStatus = "Ping UnSuccessful -- TimeToLive Expired
              >Reassembly"
              > Case 11015 PingStatus = "Ping UnSuccessful -- Parameter Problem"
              > Case 11016 PingStatus = "Ping UnSuccessful -- Source Quench"
              > Case 11017 PingStatus = "Ping UnSuccessful -- Option Too Big"
              > Case 11018 PingStatus = "Ping UnSuccessful -- Bad Destination"
              > Case 11032 PingStatus = "Ping UnSuccessful -- Negotiating IPSEC"
              > Case 11050 PingStatus = "Ping UnSuccessful -- General Failure"
              > Case Else PingStatus = "Ping UnSuccessful -- Unable to determine cause
              >of failure."
              > End Select
              >Next
              >End Function
              >>
              >Thanks In Advance,
              >Dave Marden
              >>
              >

              Comment

              Working...