Question

Please tell me how to connect and disconnect mobile broadband connection using C# or DOS?

Was it helpful?

Solution

There is no native support in .NET, you need to invoke the win api, specifically wininet.dll and invoke InternetGetConnectedState function. You can use the following link for with a sample code. Code is in VB, but you can easily convert it to c#.

OTHER TIPS

On the commandline (DOS) you can use the netsh command.

Instructions: 1) Get the mobile interface and note the name

netsh mbn show interface

Output:

There is 1 interface on the system:

Name               : Mobiel 5
Description        : Sierra Wireless EM7345 4G LTE
GUID               : xxx
Physical Address   : xxx
State              : Not connected
Device type        : Mobile Broadband device is embedded in the system
Cellular class     : GSM
Device Id          : xxx
Manufacturer       : Sierra Wireless Inc.
Model              : Sierra Wireless EM7345 4G LTE
Firmware Version   : FIH7160_V1.2_WW_01.1442.11
Provider Name      : BEL PROXIMUS
Roaming            : Yes
Signal             : 74%
RSSI / RSCP        : 23 (-67 dBm)

2) Get the connection profiles for the interface (on my system the name is "mobiel 5"

netsh mbn show profiles interface="mobiel 5"

Output

Profiles on interface Mobiel 5:
-------------------------------------
    {3623E7AB-E116-47E6-8A9B-FCC1ADBE568E}
    {F4E77FAE-D4FD-4196-86CA-852EFE8A9154}
    !!##MBIMModemProvisionedContextInternetProfile##8935299564103228197

3) Connect using the interface and profile name

netsh mbn connect interface="mobiel 5" connmode=name name="{F4E77FAE-D4FD-4196-86CA-852EFE8A9154}"

4) Disconnect using the interface name

netsh mbn disconnect interface="mobiel 5"

This works on Windows 10

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top