VBS ping atma ve yanıta göre işlem
Visual Basic Script ile bir makinaya ping atma ve gelen yanıta göre cihaza ulaşılabiliyor ise ona göre işlem yapabilmek için gerekli kodlar..
strHost="www.google.com" if Ping(strHost) = True then 'Wscript.Echo "Host " & strHost & " contacted" MsgBox("Baglanti VAR") Else 'Wscript.Echo "Host " & strHost & " could not be contacted" MsgBox("HATA") end if Function Ping(strHost) dim objPing, objRetStatus set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _ ("select * from Win32_PingStatus where address = '" & strHost & "'") for each objRetStatus in objPing if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then Ping = False 'WScript.Echo "Status code is " & objRetStatus.StatusCode else Ping = True 'Wscript.Echo "Bytes = " & vbTab & objRetStatus.BufferSize 'Wscript.Echo "Time (ms) = " & vbTab & objRetStatus.ResponseTime 'Wscript.Echo "TTL (s) = " & vbTab & objRetStatus.ResponseTimeToLive end if next End Function