;; Simple alias using com objects to test if a IP/Host is pingable
;; $_ping(host)
;; returns Time=Xms
;; or
;; returns $false
alias _ping {
var %x = $ticks,%p = $$1,%f = c:\ $+ %p $+ .txt
if ($com(ping $+ %x)) { .comclose ping $+ %x }
.comopen ping $+ %x WScript.Shell
if !$comerr { .comclose ping $+ %x $com(ping $+ %x,Run,3,bstr,cmd.exe /c ping %p -n 1 -w 1000 > %f,uint,0,bool,true) }
%p = $read(%f,n,4)
if (: isin %p) { .remove %f | return $gettok($gettok(%p,2-,58),2,32) }
else { .remove %f | return $false }
}