Help for checking internet connection and restarting modem

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
dipzx
Newbie
Posts: 2
Joined: Mon Dec 28, 2009 11:26 am
Location: UAE

Help for checking internet connection and restarting modem

Post by dipzx » Mon Dec 28, 2009 11:37 am

Hey Guys
i am really new Bi for Macros
and i really will appreciate if some one can help me to solve my problem.

I use to surf my personal PC from my office Pc by logme in & Team Viwer for downloading files from free server

my problem is sometime my wifi driver use to crash so i need to restart my pc and some times my modem use to hangup so i need to restart it

i can setup script that can restart both one by one every hour or two hour

but i want a script/macro that can check for my internet connect like by ping to my modem or some site and if internet connection is not working it can trigger to to some exe file so it can restart my pc and reboot modem after restart.

so in short i am looking for help to develop macro that can check for internet connection like every 15 min and trigger pc & modem reboot if internet is disconnected.

pls guys help me out
thanks in advance
In God I Trust For Rest I Do Virus Scan

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Dec 28, 2009 7:41 pm

This script can ping a domain name or host IP.

Pinging a domain

Code: Select all

VBSTART
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
      'MsgBox "Status code is " & objRetStatus.StatusCode
    else
      Ping = True
      'MsgBox "Bytes = " & vbTab & objRetStatus.BufferSize & vbCRLF & _
      '       "Time (ms) = " & vbTab & objRetStatus.ResponseTime & vbCRLF & _
      '       "TTL (s) = " & vbTab & objRetStatus.ResponseTimeToLive
    end if
  next
End Function
VBEND


Label>PingLoop
//Wait 1 second
wait>1
//Change to any website. I'm using google.com in this example
VBEval>Ping("google.com"),pinged
If>pinged=True
  MessageModal>host contacted
Else
  MessageModal>host not contacted
  //Restart Modem/PC
Endif
Goto>PingLoop

Pinging a host IP

Code: Select all

VBSTART
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
      'MsgBox "Status code is " & objRetStatus.StatusCode
    else
      Ping = True
      'MsgBox "Bytes = " & vbTab & objRetStatus.BufferSize & vbCRLF & _
      '       "Time (ms) = " & vbTab & objRetStatus.ResponseTime & vbCRLF & _
      '       "TTL (s) = " & vbTab & objRetStatus.ResponseTimeToLive
    end if
  next
End Function
VBEND


Label>PingLoop
//Wait 1 second
wait>1
//Change to any host IP you like. I'm using Google's IP in this example.
VBEval>Ping("72.14.209.104"),pinged
If>pinged=True
  MessageModal>host contacted
Else
  MessageModal>host not contacted
  //Restart Modem/PC
Endif
Goto>PingLoop

dipzx
Newbie
Posts: 2
Joined: Mon Dec 28, 2009 11:26 am
Location: UAE

Thanks

Post by dipzx » Tue Dec 29, 2009 6:05 am

Thanks mate
thank you very much
In God I Trust For Rest I Do Virus Scan

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts