• 0

Big favour to ask


Question

Hi,

Basically this is only very small but I have no idea how to start. I was thinking it could be achieved with a simple batch file or script but im not sure.

I need a program that will tell the user whether the Internet is connected (will be run on startup on networked machines without a direct Internet connection). Possibly done by pinging a reliable website - and if the request times out, a message is displayed saying "Internet Offline" or something like that, and if the ping is successful, then nothing happens and the program exits.

Thanks!

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

if they are on a network cant u just have the connection icon in the system tray? wouldnt that tell you wether u are connected or not?

Link to comment
Share on other sites

  • 0
im pretty sure plenty of freeware will do this...

Could you recommend one then please as i've been looking for quite a while Thanks

Link to comment
Share on other sites

  • 0

This should do the trick ;)

I put it together rather quickly, and haven't really tested it, so you'll have to see if it works or not.

It checks against www.google.com to determine if there is an internet connection present.

Have included source (couple of lines anyway) if interested to see how it was done.

hope that helps,

bwx

checkInet.zip

Link to comment
Share on other sites

  • 0
This should do the trick ;)

I put it together rather quickly, and haven't really tested it, so you'll have to see if it works or not.

It checks against www.google.com to determine if there is an internet connection present.

Have included source (couple of lines anyway) if interested to see how it was done.

hope that helps,

bwx

:D

That is brilliant, just what I was looking for!

Thanks a lot for helping me out :) . If you ever need a favour *not* re programming :blush: than im your man lol ;)

Link to comment
Share on other sites

  • 0

What did you use to make the program? I was having a mess around with the code in notepad and if I just save it in notepad as an EXE it crashes.

Thanks

Link to comment
Share on other sites

  • 0
What did you use to make the program? I was having a mess around with the code in notepad and if I just save it in notepad as an EXE it crashes.

Thanks

Yeah, you need to compile it using a C compiler, just saving the .c file as a .exe won't work because it needs to be translated into assembly (machine instructions) and then that assembly is translated into 1's and 0's.

Link to comment
Share on other sites

  • 0

try this in a filename.bat file:

@echo off

set google=0
set yahoo=0
set msn=0

echo Pinging ....

ping www.google.com
if errorlevel 1 set google=1

ping www.yahoo.com
if errorlevel 1 set yahoo=1

ping www.msn.com
if errorlevel 1 set msn=1
i
f %google%==1 goto yahoo
goto fine

:yahoo
if %yahoo%==1 goto msn
goto fine

:msn
if %msn%==0 goto fine

echo CANNOT SEE GOOGLE, MSN + YAHOO
echo YOU ARE MOST LIKELY NOT CONNECTED
GOTO end

:fine
echo CAN SEE A SITE
echo YOU ARE CONNECTED

:end

Link to comment
Share on other sites

  • 0

bwx's proggy is pretty cool.

But I'm bored out of my mind.

So if any of you likes Java, here is my source code for it. Go nuts.

import java.net.*;
import java.io.*;
import java.util.Date;
import java.util.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class InConn extends JFrame {

     public static void main (String[] args)  //Main class
     {

       JFrame theFrame = new InConn();
       theFrame.setSize(300, 70);
       theFrame.setVisible(true);
       theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      }

    private JLabel    lbResult   = new JLabel   ("The Internet connection is Working!");

     public InConn(){



       Container contentPane = getContentPane();
       FlowLayout layout = new FlowLayout();
       contentPane.setLayout(layout);

       contentPane.add (lbResult);
       try{
       Checks();
       if (!((Checks()).equals("good")))
            lbResult.setText("The internet conection might be off");
             }
       catch (Exception e){};

     }




     public String Checks () throws Exception{
        int c;
        String str ="good";
        URL hp = new URL("http://www.google.com");
        URLConnection hpCon = hp.openConnection();
        String[] commandHolder = new String[7];
        int countCommand = 0;
        long d = hpCon.getDate();
        StringTokenizer st = new StringTokenizer(new Date(d).toString());

       while (st.hasMoreTokens()) {
             commandHolder[countCommand] = st.nextToken(); //holds the tokens

             countCommand++;  //the variable incrementer
       }
       if ((Integer.parseInt(commandHolder[5]))<2000)
              str = "Notgood";

       return str;
       }
}

:sleep:

Link to comment
Share on other sites

  • 0

:huh: I swear I had this thought about 5 minutes before I saw this thread.

I was lying in bed attempting to sleep (need to wake up in 4 hours) and noticed my cable modem was cycling.

Then thought to myself, I know.. I could write up a program that plays some really annoying sound when my internet connection dies out.

And it's officially coffee time, *gives in to the not so sandy man*

Link to comment
Share on other sites

  • 0
I like your commenting :D

Thanx. But damn is true. While i'm in univ i can't wait until the semester is over. And now that it is over i don't know what to do to keep busy during the day.

meh...guess writing some code is the way to keep from losing my mind.

:rofl:

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.