diff --git a/Disco.Client/Interop/Native/WlanApi.cs b/Disco.Client/Interop/Native/WlanApi.cs index dc39290f..5f1e1818 100644 --- a/Disco.Client/Interop/Native/WlanApi.cs +++ b/Disco.Client/Interop/Native/WlanApi.cs @@ -11,6 +11,7 @@ namespace Disco.Client.Interop.Native public const int ERROR_SUCCESS = 0; public const int ERROR_INVALID_PARAMETER = 87; public const int ERROR_NOT_ENOUGH_MEMORY = 8; + public const int ERROR_SERVICE_NOT_ACTIVE = 1062; // The service has not been started. /// /// The WlanOpenHandle function opens a connection to the server. diff --git a/Disco.Client/Interop/WirelessNetwork.cs b/Disco.Client/Interop/WirelessNetwork.cs index ea58ac1f..aea56f21 100644 --- a/Disco.Client/Interop/WirelessNetwork.cs +++ b/Disco.Client/Interop/WirelessNetwork.cs @@ -71,6 +71,13 @@ namespace Disco.Client.Interop // Connect to wireless service interopResult = WlanApi.WlanOpenHandle(WlanApi.WLAN_API_VERSION_2_0, IntPtr.Zero, out wlanServiceVersion, out wlanHandle); + if (interopResult == WlanApi.ERROR_SERVICE_NOT_ACTIVE) + { + // Indicates the Wlan service has not been started on the client + // typically as it is not needed (no wireless adapter) or if it + // has been forcibly disabled. + return null; + } if (interopResult != WlanApi.ERROR_SUCCESS) { throw new Exception($"Unable to connect to local wireless service. WlanOpenHandle returned: {interopResult}"); @@ -156,6 +163,14 @@ namespace Disco.Client.Interop // Connect to wireless service interopResult = WlanApi.WlanOpenHandle(WlanApi.WLAN_API_VERSION_2_0, IntPtr.Zero, out wlanServiceVersion, out wlanHandle); + if (interopResult == WlanApi.ERROR_SERVICE_NOT_ACTIVE) + { + // Indicates the Wlan service has not been started on the client + // typically as it is not needed (no wireless adapter) or if it + // has been forcibly disabled. + Presentation.UpdateStatus("Enrolling Device", $"Configuring Wireless Profiles\r\nSkipping, the WLAN service is not enabled", true, -1, 3000); + return; + } if (interopResult != WlanApi.ERROR_SUCCESS) { throw new Exception($"Unable to connect to local wireless service. WlanOpenHandle returned: {interopResult}");