Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent the Network Location dialog (home, work, public) appearing for new connections?

I've written a piece of software that uses an USB 3G Dongle to connect to the internet if a connection doesn't already exist.

When the software loads, it detects whether the internet is available and if not, then creates a dial up connection (via RAS) and then dials it.

If this happens for the first time, the network location dialog comes up asking the user to select whether it's home, work or public.

Is there anyway, I can either programatically set the network location of a connection, or even tell windows not to show the dialog and automatically set the location to public?

Cheers

Gavin

Edit: For ScottM

public bool Connect(bool monitorSignalUpdates)
{
    RasPhoneBook rpb = new RasPhoneBook();
    rpb.Open(true);
    if (!rpb.Entries.Contains("3G Connection"))
    {
        rpb.Entries.Add(RasEntry.CreateBroadbandEntry("3G Connection", RasDevice.GetDeviceByName("HUAWEI Mobile Connect - 3G Modem", RasDeviceType.Modem), true));
    }
    _rd = new RasDialer();
    _rd.EntryName = "3G Connection";
    _rd.PhoneNumber = "*99#";
    try
    {
        _rd.Dial();
        if (monitorSignalUpdates)
        {
            _queryPort.DataReceived += new SerialDataReceivedEventHandler(_queryPort_DataReceived);
        }
        return true;
    }
    catch (Exception ex)
    {
        int i = 99;
    }
    return false;
}
like image 277
Gavin Avatar asked Jun 27 '11 05:06

Gavin


1 Answers

This registry entry controls whether Windows will prompt for ("Home/Work/Public"):

HKLM\System\CurrentControlSet\Control\Network\NewNetworkWindowOff

http://technet.microsoft.com/en-us/library/gg252535%28v=ws.10%29.aspx

You can always "“Turn off Notification on New Networks” from system tray :)

And if you can do that, I'm sure there's a registry hack and/or a PowerShell API for doing the same:

http://technet.microsoft.com/en-us/library/cc725831%28v=ws.10%29.aspx

like image 65
paulsm4 Avatar answered Oct 22 '22 21:10

paulsm4