curiousbrad Posted May 4, 2009 Share Posted May 4, 2009 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 Link to comment Share on other sites More sharing options...
Zinthose Posted May 4, 2009 Share Posted May 4, 2009 (edited) ;## 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 May 4, 2009 by Zinthose --- TTFN Link to comment Share on other sites More sharing options...
rajeshontheweb Posted May 5, 2009 Share Posted May 5, 2009 (edited) 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. expandcollapse popup' 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 May 9, 2009 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now