pppoe

Redialing a PPPOE connection programmatically


I have a PPPOE connection on a computer. That computer has two LAN cards and I activated ICS on it. The problem is, the connection kinda degrades over time (don't know why), and a redial would be nice, hourly maybe. I was thinking of writing an AutoIT script that would do this, if, for example I'm sending some data to a port the gateway pc is listening on. The only trouble is, I don't know what's the name of the executable I would have to run.

EDIT: I'm interested in the one with the GUI.

EDIT 2: I am interested in automating this process, and wouldn't like to have to write the thing in AutoIT (this a last resort option).


Solution

  • you can use rasdial (which is build in into windows) and create a batch script (.bat extension) like so:

    rasdial connectionname
    

    -or-

    if you want to do it in a programming language, you can just call the command internally

    C# example:

    public static int OpenConnection(string connectionName, int Timeout) {
       int ExitCode;
       ProcessStartInfo ProcessInfo;
       Process Process;
    
       ProcessInfo = new ProcessStartInfo("cmd.exe", "/C rasdial " + connectionName);
       ProcessInfo.CreateNoWindow = true; 
       ProcessInfo.UseShellExecute = false;
       Process = Process.Start(ProcessInfo);
       Process.WaitForExit(Timeout);
       ExitCode = Process.ExitCode;
       Process.Close();
    
       return ExitCode;
    }
    

    and I guess your desired language will have something like this available as well.

    oh and you can use:

    rasdial "connection name" /d 
    

    to drop the connection.