Set "Default remote connection" property after created Dialup profile

Sep 9, 2011 at 3:02 PM

Hi to all. How can I set "This is the default dialup profile" property after created a new Dialup profile with code

rasEntry  = RasEntry.CreateDialUpEntry(item.Name, item.PhoneNumber, rasDevice);
rasPhoneBook.Entries.Add(rasEntry);          

and added it to the system PhoneBook??

I need to replicate the funcion as when I go to Control Panel/Network and Internet/Network Connections, right mouse click over the desired profile and choose "Set as default connection"; after this, a green circle appears near the profile Icon.

The same behavior if I'm in Internet Option panel, Connection tab, enable "Use always default remote connection" option and the click "Default" button after selected the desired profile on list.

Is this possible?? Thanks

Win7/.NET Framework 2.0

Coordinator
Sep 10, 2011 at 2:31 AM

I've never figured out how to do it, and as far as I can tell there is no documentation what is actually going on under the hood in Windows when you tell it to make a connection the default. It may have something to do with the RAS AutoDial mechanism, which has been exposed as the RasAutoDialManager class but as for the actual use of the component I'm not exactly sure how the underlying API works. I implemented something that I thought would make sense but haven't got a lot of feedback on that component.

If you can find a way to do this using the RAS API I'd be all ears so I can get it documented within the project, however if you find that it's modification of a registry key or using an external executable I'm afraid there's nothing I can do about it. Those sorts of things are out of scope of the project (and usually end up being removed from this forum) and aren't something I'd be willing to maintain.

Wish I had better advice, sorry.

- Jeff

Sep 15, 2011 at 2:38 PM

Thanks jeff

as soon as possible I will try the RasAutoDialManager class searching for something about setting the default profile. If I will found something intersting I'll let you know for sure!

minimega

Sep 16, 2011 at 8:45 AM

As expected, it' only a registry key. I've find any API to use for setting default profile proprerty. In case you want to include .SetDefault() method or .Default property for RasEntry class or someone want to set manually this property, this is the way:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\RAS AutoDial\Default\DefaultInternet REG_SZ "Dialup Profile Name" for connections shared with All Users

HKEY_CURRENT_USER\SOFTWARE\Microsoft\RAS AutoDial\Default\DefaultInternet REG_SZ "Dialup Profile Name" for connections owned only by logged user

So if you wat to set as default the RasEntry created in the user phonebook (opened with rasPhoneBook.Open(true)) you have to write the RasEntry name in HKEY_CURRENT_USER and empty the key in HKEY_LOCAL_MACHINE;

if you wat to set as default the RasEntry created in the system phonebook (opened with rasPhoneBook.Open(false)) you have to write the RasEntry name in HKEY_LOCAL_MACHINEand empty the key in HKEY_CURRENT_USER;

After changed the value in the registry, press F5 in Network Connections control panel to get the list refreshed and the "good green ribbon" over the selected connection.

minimega