controling Wi-Fi setting and Bluetooth setting with python

Mr Avishka Induwara 20 Reputation points

I am creating a new game assistance software in python. is there any way to control wi-fi and Bluetooth and other wireless and wired connection with python. like any API released by Microsoft.

Windows for IoT
Windows for IoT
A family of Microsoft operating systems designed for use in Internet of Things (IoT) devices.
383 questions
Windows Performance Toolkit
Windows Performance Toolkit
A collection of Microsoft performance monitoring tools that produce in-depth performance profiles of Windows operating systems and applications.
97 questions
0 comments No comments
{count} votes

Accepted answer
  1. Khaled Elsayed Mohamed 1,260 Reputation points

    Hi Avishka

    Yes, you can control Wi-Fi, Bluetooth, and other network connections using Python. Microsoft provides a set of APIs called the Windows Device Portal (WDP) that allows programmatic management of various aspects of a Windows device, including network connections. The WDP provides a RESTful API that can be accessed using Python or any other programming language capable of making HTTP requests.

    Here's a high-level overview of how you can control network connections using Python and the Windows Device Portal API:

    Enable the Windows Device Portal on your Windows device:

    • Go to "Settings" > "Update & Security" > "For developers".
    • Enable "Developer mode".
    • Enable "Device discovery" under "Device portal".
    • Note the URL and credentials (username and password) displayed on the page.

    Install the necessary Python libraries:

    • Install the "requests" library, which allows you to make HTTP requests in Python. You can install it using pip: pip install requests.

    Write Python code to interact with the Windows Device Portal API:

    • Import the "requests" library in your Python script.
    • Use the requests library to make HTTP requests to the Windows Device Portal API endpoints.
    • Authenticate by including the username and password in the request headers or by using the session authentication feature of the requests library.
    • Use the appropriate API endpoints to control Wi-Fi, Bluetooth, or other network connections. The API provides methods for enabling/disabling connections, scanning for available networks, connecting to a specific network, etc.

    Here's a simple example that demonstrates how to disable Wi-Fi using the Windows Device Portal API in Python:

    import requests
    # Specify the URL of your Windows device's Device Portal
    device_portal_url = 'http://<device-ip-address>/api'
    # Specify the username and password for authentication
    username = 'admin'
    password = 'password'
    # Disable Wi-Fi using the Device Portal API
    url = f'{device_portal_url}/interfaces/wifi/state'
    headers = {'Content-Type': 'application/json'}
    data = {'state': False}
    response =, headers=headers, auth=(username, password), json=data)
    # Check the response status
    if response.status_code == 200:
        print('Wi-Fi disabled successfully.')
        print('Failed to disable Wi-Fi.')
        print('Response:', response.text)

    Note that this is a simplified example, and you may need to refer to the Windows Device Portal API documentation for more specific details on controlling different types of network connections.

    Please refer to the official Microsoft documentation for the Windows Device Portal API for more information and detailed API reference: Windows Device Portal API.

    Keep in mind that controlling network connections may require administrative privileges, so make sure you run your Python script with appropriate permissions.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Khaled Elsayed Mohamed 1,260 Reputation points

    Hi Mr Avishka Induwara

    If you encounter the error message "The Windows Developer Mode package couldn't be found in Windows Update, so deployment and Windows Device Portal are unavailable" when trying to enable developer mode in Windows 10, there are a few steps you can take to resolve the issue:

    Check Windows Update: Ensure that your Windows system is up to date. Go to "Settings" > "Update & Security" > "Windows Update" and click on "Check for updates." Install any pending updates and restart your computer if necessary.

    Enable Developer Mode via Settings: Try enabling developer mode through the Windows Settings app. Follow these steps:

    • Go to "Settings" > "Update & Security" > "For developers."
    • Under the "Use developer features" section, select the "Developer mode" option.

    Enable Developer Mode via Group Policy: If the above method doesn't work, you can try enabling developer mode using Group Policy. Here's how:

    • Press Win + R to open the Run dialog box, then type gpedit.msc and press Enter.
    • In the Local Group Policy Editor, navigate to "Computer Configuration" > "Administrative Templates" > "Windows Components" > "App Package Deployment."
    • Double-click on "Allow all trusted apps to install."
    • Select the "Enabled" option and click "Apply" and "OK."
    • Restart your computer and try enabling developer mode again through the Settings app.
    1. Check Windows Developer Mode Package: If the issue persists, you can manually check if the Windows Developer Mode package is installed on your system. Follow these steps:
    • Open PowerShell as an administrator.
      • Run the following command to check if the Windows Developer Mode package is installed:
          Get-WindowsCapability -Online | Where-Object {$_.Name -like "*DeveloperMode*"}
       - If the package is not listed, you can try installing it using the following command:
          Add-WindowsCapability -Online -Name "DevTools~~" -LimitAccess
       - Restart your computer and check if you can enable developer mode without encountering the error message.  
          also, you can check similar error:  
    0 comments No comments