Jump to content
Sign in to follow this  
curiousbrad

determine whether a computer on a local network is available through WMI ?

Recommended Posts

curiousbrad

Hi guys

Just trying to figure out / wondering if anyone knows the best way to determine whether a computer on a local network is available.

Said computer has a static ip and is running server 2008 standard

I have been playing with the ping command, but it seems sort of sloppy and was hoping that someone might know if it can be done through WMI ? .

Im looking for a persistent way to watch if the server is online and is reachable.

regards

Share this post


Link to post
Share on other sites
Zinthose

;## If the system has a particular service you need to verify is available, you can simply connect to that service and validate that way.
;## EXAMPLES

TCPStartup()

TCPConnect("192.168.1.11", 80);  <== Validates HTTP Server
If @error Then
    ;## This Server is Offline.
EndIf

TCPConnect("192.168.1.12", 21);  <== Validates FTP Server
If @error Then
    ;## This Server is Offline.
EndIf

TCPConnect("192.168.1.12", 666);  <== Doom 2 Server
If @error Then
    ;## This Server is Offline.
EndIf

TCPShutdown()

Edited by Zinthose

--- TTFN

Share this post


Link to post
Share on other sites
rajeshontheweb

sorry i was searching for what i had used - this is based on script i got from the internet, modified to my use to retrieve IP address also.

' based on [url="http://msdn.microsoft.com/en-us/library/aa394350(loband).aspx"]http://msdn.microsoft.com/en-us/library/aa...50(loband).aspx[/url] (had a tuf time getting to understand simple concepts :-(

URLPath = "www.robvanderwoude.com"
WScript.Echo URLPath & " on-line: " & Ping( URLPath)

URLPath = "www.google.com"
WScript.Echo URLPath & " on-line: " & Ping( URLPath)

URLPath = "Manjara22"
WScript.Echo URLPath & " on-line: " & Ping( URLPath)

URLPath = "Simpleshare"
WScript.Echo URLPath & " on-line: " & Ping( URLPath)


Function Ping(MyHostName)
' This function returns True if the specified host could be pinged.
' myHostName can be a computer name or IP address.
' The Win32_PingStatus class used in this function requires Windows XP or later.
' This function is based on the TestPing function in a sample script by Don Jones
' [url="http://www.scriptinganswers.com/vault/computer%20management/default.asp#activedirectoryquickworkstationinventorytxt"]http://www.scriptinganswers.com/vault/comp...ioninventorytxt[/url]

    ' Standard housekeeping
    Dim colPingResults, objPingResult, strQuery

    ' Define the WMI query
    strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & myHostName & "'" '& " AND ResolveAddressNames = " & True 

    ' Run the WMI query
    Set colPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery( strQuery )

    ' Translate the query results to either True or False
    For Each objPingResult In colPingResults
        If Not IsObject( objPingResult ) Then
            Ping = False
        ElseIf objPingResult.StatusCode = 0 Then
            'WScript.Echo objPingResult.ProtocolAddress
            'Ping = True
            Ping = "True, With the IP" & objPingResult.ProtocolAddress
        Else
            Ping = False
        End If
    Next
    Set colPingResults = Nothing
End Function

its the original vbscript i have, ofcourse, will post autoit script later on if needed.

Edited by rajeshontheweb

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.