Is there an easy way to check if a server exists on the network using VBScript?

I have the ultimate goal of determining that a specific database on a specific server with specific credentials is running, but at this point I would decide to check and see if the server is really on the network. Does anyone have a way to do this? I seem to be drawing a space.

Michael

+3
source share
4 answers

try it

Dim target
Dim result

target= "172.19.130.96"

Set shell = WScript.CreateObject("WScript.Shell")

Set shellexec = shell.Exec("ping " & target) 

result = LCase(shellexec.StdOut.ReadAll)

If InStr(result , "reply from") Then
  WScript.Echo "Server alive"  
Else
  WScript.Echo "Not Alive"
End If

There may be better ways, especially considering the ultimate goal, but this should work and at least point you in the right direction.

+3
source

, Win32_PingStatus WMI ( : Windows XP ):

strServer = "stackoverflow.com"

Set oWMI = GetObject("winmgmts:\\.\root\cimv2")
Set oPing = oWMI.Get("Win32_PingStatus.Address='"& strServer & "'")

If oPing.StatusCode = 0 Then 
   WScript.Echo "Server is available."
Else
   WScript.Echo "Server is not available."
End If

ping script : script Windows 2000?

+2

ping, -, script , , , .

Dim target
Dim result

target= "172.19.130.96"

Set shell = WScript.CreateObject("WScript.Shell")

Set shellexec = shell.Exec("ping -n 1 " & target)

result = LCase(shellexec.StdOut.ReadAll)

If InStr(result , "reply from") Then
  WScript.Echo "Server alive"  
Else
  WScript.Echo "Not Alive"
End If
+2

, , , nmap. vbscript, exec(), .

0

Source: https://habr.com/ru/post/1738565/


All Articles