Check Internet Connection

By ^WeSt on Feb 05, 2015

Requested by: Unknown


Credits to: Wims


This code is checking if you have internet connection available via mIRC, if you get 1 on $internet return that means that you have internet connection if you get 0 on return that means that you have NOT an internet connection, NOTE that if on the first time you use $internet may stuck for a while to find the correct internet adapter that your machine uses to check for internet connection but this will happen only one time per mIRC open.

Example 1: //echo -a Internet Connection: $internet
Example 2: //echo -a My Internet Connections is: $iif($internet,Connected,NOT Connected)

  • Enjoy!
ON *:START: { internet }
alias internet {
  var %h = $hget(INTERNET,CON)
  if (%h) {
    var %s = $wmiget(Win32_NetworkAdapter,%h).NetConnectionStatus
    if (%s) && (%s == 2) { $iif($isid,return 1,return) }
    else { $iif($isid,return 0,return) }
  elseif (!%h) {
    var %t = $wmiget(Win32_NetworkAdapter,N).NetConnectionStatus
    if (!%t) { $iif($isid,return 0,return) }
    var %i = 1
    while (%i <= %t) {
      var %s = $wmiget(Win32_NetworkAdapter,%i).NetConnectionStatus
      hadd -m INTERNET CON %i
      if (%s) && (%s == 2) { $iif($isid,return 1,return) }
      inc %i
  $iif($isid,return 0)

alias wmiget {
  var %ar = a $+ $ticks $+ $ctime
  var %br = b $+ $ticks $+ $ctime
  var %cr = c $+ $ticks $+ $ctime
  .comopen %ar WbemScripting.SWbemLocator
  if ($comerr) { .comclose %ar | return 0 }
  .comclose %ar $com(%ar,ConnectServer,3,dispatch* %br)
  if ($comerr) { return 0 }
  .comclose %br $com(%br,ExecQuery,3,bstr*,select $prop from $1,dispatch* %cr)
  var %x = $comval(%cr,$iif($2,$2,1),$prop)
  if ($com(%ar)) { .comclose %ar }
  if ($com(%br)) { .comclose %br }
  if ($com(%cr)) { .comclose %cr }
  return $iif(%x,%x,0)


Sign in to comment.
Hawkee   -  Feb 05, 2015

Might be a good idea to start your page with the description. Your profile will only list the first paragraph of each page, so you're ending up with a lot of "Requested by" lines rather than descriptive text.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.