This project is read-only.

Creating a DotRas in VB2010 Help

Nov 25, 2010 at 3:42 AM

Hi Everyone.

I'm trying to learn VB2010.

Does anyone have a sample for the DotRas 1.2 using the L2TP with Pre-shared key?

I have tried to do it myself but keep failing I can only manage to do the PPTP.

If you have one that would be great to show me please so I can learn how to do these things.

Many Thanks

Nov 25, 2010 at 4:09 AM
Edited Nov 26, 2010 at 3:59 AM
Dim pbk As New RasPhoneBook

Dim entry As RasEntry = RasEntry.CreateVpnEntry("VPN Connection", "", RasVpnStrategy.L2tpOnly, RasDevice.GetDeviceByName("(L2TP)", RasDeviceType.Vpn))


' The entry must be added to the phone book before the update credentials method can be called. (Windows requirement)

entry.UpdateCredentials(RasPreSharedKey.Client, "YourKeyHere")

That should get you what you need to create and save an L2TP preshared key for the entry in the default phone book. Also, you will need to use the WINXP or later build since Windows 2000 doesn't support pre-shared keys.

Edit: Had to fix an error in the posted example.

Nov 25, 2010 at 9:59 PM

Hi jeff_winn

I have tried that but it doesn't work

It doesn't set the pre-shared key in the options


Nov 25, 2010 at 10:04 PM

Hi jeff_winn

I have added this and it works now

entry.Options.UsePreSharedKey = True

Another question please.

If the entry is there and I click create entry again it comes up with an error.

How can I make it so it erases the entry on application close?

Thank you


Nov 26, 2010 at 3:56 AM
Edited Nov 26, 2010 at 3:59 AM

You just need to remove the entry from the phonebook. However, it would be just as effective to store the entry in a custom phone book next to your application and create it once. Entries that are not in the all user profile or user profile phonebooks do not show up in the network connections window.

Dim pbk As New RasPhoneBook

pbk.Entries.Remove("VPN Connection")

Edit: Added an example to the post.

Nov 26, 2010 at 4:11 AM
Hi Jeff, Is there a guide to show how to create a custom phonebook please? Thank you
Nov 26, 2010 at 7:49 AM

The stuff you're trying to do is not that complicated. Try reading the help documentation... I'm not going to keep answering every tiny little question while you try and write your application. I've been patient so far, but even I have limits. The documentation is quite detailed, you shouldn't have any problem finding what you need if you actually look at it.