I want to control RadioState of Wifi and Mobile(cellular) connection in Windows 10 x64 using custom application written in VB. It works for Wifi radio but doesn't for MobileBroadband.
Actually code does the same job as click on ActionCenter in Windows 10 and press Wifi or Cellular button.
Private Async Sub TurnMobileOnOff(arg As Integer)
Dim access = Await Windows.Devices.WiFi.WiFiAdapter.RequestAccessAsync
Dim radios = Await Windows.Devices.Radios.Radio.GetRadiosAsync
If access = Windows.Devices.WiFi.WiFiAccessStatus.Allowed Then
For Each radio In radios
If radio.Kind = Windows.Devices.Radios.RadioKind.MobileBroadband Then
If arg = 1 Then
Await radio.SetStateAsync(Windows.Devices.Radios.RadioState.On)
RichTextBox1.AppendText(vbCrLf & "Mobile connection is turninng on")
ElseIf arg = 0 Then
Await radio.SetStateAsync(Windows.Devices.Radios.RadioState.Off)
RichTextBox1.AppendText(vbCrLf & "Mobile connection is turninng off")
End If
End If
Next
End If
End Sub
There's no error message, just radiostate is unchanged. The same code works for WiFi as expected.
Source:https://learn.microsoft.com/en-us/uwp/api/windows.devices.radios.radiostate
Thank for any help.