Hello,
Can someone give me an idea on how to start and control a pppoe connection using code and not using rasdial.
Oh and i would also like to be able to specify the phonebook that i would like to use with full path.

Thank you,
Daniel

Dani AI

Generated

Short summary and practical options for (and note to ): the simplest robust choices are (A) call the Windows RAS API directly from VB.NET via P/Invoke (no external process), or (B) use the managed DotRas library (ready-made wrapper with events). Running rasdial.exe from Process and parsing its output works, but it is brittle and gives you no native event/state callbacks.

Calling the native RAS API lets you dial, hang up and monitor connections programmatically. RasDial accepts a phone-book (.pbk) full path, returns a connection handle, and you can call RasHangUp to disconnect. Use RasEnumConnections and RasGetConnectStatus (or RasConnectionNotification) to enumerate and reliably track connection state rather than polling NetworkInterface. For PPPoE you create a broadband/PPPoE RAS entry (RASET_Broadband / RASDT_PPPoE) before dialing. (learn.microsoft.com)

DotRas is a higher‑level managed option that wraps the RAS API, exposes a RasDialer (with PhoneBookPath, EntryName, Credentials), state-change events, and phone-book management helpers — this avoids manual P/Invoke and output parsing. If you prefer a ready component, add DotRas and use RasDialer.Dial or DialAsync and handle StateChanged for progress/errors. (github.com)

Example (VB.NET, needs DotRas.dll):

Dim dialer As New DotRas.RasDialer()
Try
  dialer.EntryName = "MyPPPoE"
  dialer.PhoneBookPath = "C:\path\to\MyPhonebook.pbk"
  dialer.Credentials = New System.Net.NetworkCredential("user","pass")
  dialer.Dial()   ' or DialAsync and handle StateChanged
Finally
  dialer.Dispose()
End Try

Caveats & tips: editing or using an All‑Users phonebook may require placing the .pbk under the common appdata folder for Windows and/or elevated rights — some RAS phone-book behaviors vary across Windows versions, so test on target OS builds. Prefer RasEnumConnections/RasGetConnectStatus over NetworkInterface for reliable status and call RasHangUp then wait for ERROR_INVALID_HANDLE before exiting. (learn.microsoft.com)

Recommended Answers

All 2 Replies

Hello,
Can someone give me an idea on how to start and control a pppoe connection using code and not using rasdial.
Oh and i would also like to be able to specify the phonebook that i would like to use with full path.

Thank you,
Daniel

Use Process and ProcessInfo classes. Take a look AT and .

Hmmm i'm not sure that can help me.
How can i use task schedule to do this?

Curently i start a process that starts rasdial with the desired parameters. I wait for it to finish and i read the output to see if it was succesful or not.
then i use this to check if it's still up

Public Function CheckConnection() As Boolean

        Dim ni As System.Net.NetworkInformation.NetworkInterface() = _
               System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
        For Each Items As System.Net.NetworkInformation.NetworkInterface In ni
            If Items.Name = [connection name[ Then
                Return Items.OperationalStatus
                Exit Function
            End If
        Next
        Return 0
    End Function

My question is if there is the way to start the connection without using rasdial. Actualy without starting a process. I'm not sure i am explaining right.
Using windows api or something like that.


Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.