$com problem not getting result - 05/10/14 05:34 PM
hi,
I'm trying to convert this vbscript to mirc $com, and i cannot get the result.
I know i can use $com to eval vbscript and get the result, but my desire is to convert/translate into mirc scripting because now im trying to learn and trying to understand how $com working especially when vbs looping the object variable.
this is my converted code so far, but im not getting any result from it.
I hope someone can help me understand more about $com.
I'm trying to convert this vbscript to mirc $com, and i cannot get the result.
Code:
Dim wmiQuery, objWMIService, objPing, objStatus strHost = "google.com" wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strHost & "'" Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set objPing = objWMIService.ExecQuery(wmiQuery) For Each objStatus in objPing If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then ResolveIP = "Computer is Unreachable!" Else ResolveIP = objStatus.ProtocolAddress End If Next wscript.echo ResolveIp
I know i can use $com to eval vbscript and get the result, but my desire is to convert/translate into mirc scripting because now im trying to learn and trying to understand how $com working especially when vbs looping the object variable.
this is my converted code so far, but im not getting any result from it.
Code:
host2ip { :inittialize var %a $+(WbemScripting.SWbemLocator.,$ticks), %b $+(WbemScripting.SWbemLocator.,$calc($ticks + $r(11111,99999))) if ($com(%a)) goto inittialize .comopen %a WbemScripting.SWbemLocator echo -s Dispatch -> $com(%a,ConnectServer,3,dispatch* %b) .comclose %a var %query SELECT * FROM Win32_PingStatus WHERE Address = $+(',$1,') if ($com(%b)) { echo Query -> $com(%b,ExecQuery,1,bstr*,%query,dispatch* %a) .comclose %b } %c = $comval(%a,0) echo Comval -> %c echo -s -> $comval(%a,0,ProtocolAddressResolved) .comclose %a if ($com(%b)) .comclose %b }
I hope someone can help me understand more about $com.