Windows Vista Forums

Help pulling "pingable" IP of local machine into a variable
  1. #1



    Newbie
    Join Date : Feb 2010
    Posts : 1
    Vista Business x64
    Local Time: 11:52 AM

    Help pulling "pingable" IP of local machine into a variable

    Ok, here's my need. I am writing a script that does a few things, but I'm having trouble just pulling the "production" IP address into a variable, to then use in the rest of the script. I've see plenty of scripts to ping remote hosts, but that's not what I need. I've also worked up a few scripts on my own, but they all pull every IP on the machine, or require you to know the intenal ID of the NIC interface you need queried. The issue with this is that the ID is assigned randomly, and it's something you just have to know.



    I'm rather new at VBScript, and I've tried to muddle through it on my own before asking, but now I need help. Any advice would be greatly appreciated.

      My System SpecsSystem Spec

  2. #2


    ylafont Guest

    RE: Help pulling "pingable" IP of local machine into a variable

    Here is a function test to see if the address is alive, hope it helps



    Function Reachable(strComputer)
    ' On Error Resume Next
    Dim wmiQuery, objWMIService, objPing, objStatus
    wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strComputer
    & "'"

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set objPing = objWMIService.ExecQuery(wmiQuery)

    For Each objStatus in objPing
    If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then
    Reachable = False 'if computer is unreacable, return False
    Else
    Reachable = True 'if computer is reachable, return true
    End If
    Next

    End Function


    "ccc2501" wrote:

    >
    > Ok, here's my need. I am writing a script that does a few things, but
    > I'm having trouble just pulling the "production" IP address into a
    > variable, to then use in the rest of the script. I've see plenty of
    > scripts to ping remote hosts, but that's not what I need. I've also
    > worked up a few scripts on my own, but they all pull every IP on the
    > machine, or require you to know the intenal ID of the NIC interface you
    > need queried. The issue with this is that the ID is assigned randomly,
    > and it's something you just have to know.
    >
    > I'm rather new at VBScript, and I've tried to muddle through it on my
    > own before asking, but now I need help. Any advice would be greatly
    > appreciated.
    >
    >
    > --
    > ccc2501
    > .
    >

      My System SpecsSystem Spec

Help pulling "pingable" IP of local machine into a variable problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
renaming Local user account and Changing "Full Name" of same Local HCSOIT VB Script 1 20 Nov 2008
How to config "local machine"-->"personal" access right? tdh Vista General 0 29 Apr 2008
What to do to access "Local Settings" and "Application Data"? Michael Moser Vista account administration 1 02 Dec 2007
How to search "globally" under the single title "Local Folders?? Philippe - Swiss Vista mail 2 10 Sep 2007
Public network connection only "Access: Local" & not Local & Inter Iain M Vista networking & sharing 1 29 Jul 2007