Can the vbscript code in this tip be modified to also return the IP address it is pinging?
http://www.mjtnet.com/forum/viewtopic.p ... light=ping
(I know I can do this with command line ping > file but I don't want to go that route.)
Get IP address from domain name using vbscript?
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Use the ProtocolAddress property:
See:
http://msdn.microsoft.com/en-us/library ... S.85).aspx
Code: Select all
VBSTART
Function Ping(strHost)
dim objPing, objRetStatus
ipAddress = ""
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 = ""
else
Ping = objRetStatus.ProtocolAddress
end if
next
End Function
VBEND
VBEval>Ping("google.com"),pinged
If>pinged<>{""}
MessageModal>Ip Address is: %pinged%
Else
MessageModal>host not contacted
Endif
http://msdn.microsoft.com/en-us/library ... S.85).aspx
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?