Search code examples
c#uwpwifiraspberry-pi3windows-iot-core-10

Get connected devices in WiFi access point (raspberry pi 3 & Windows IoT) c#


I am working in a project relating with raspberry pi 3 and windows iot. I have configured IoT on-boarding for changing it as access point. Now the access point works and i can connect with the internet through the access point.

Now i am in need of getting the connected devices from the raspberry pi 3 WiFi access point. I have tried all the mentioned tutorials and searched over every other links regarding this.

FYI, i tried manually arp -a command to get the connected devices in AP. It also works fine, but when i tried to run programmatically, it displays as "ACCESS DENIED ERROR 0x80070005"

I tried running through powershell using process launcher i get the same error. Also have given permission

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\EmbeddedMode\ProcessLauncher /v AllowedExecutableFilesList /t REG_MULTI_SZ c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe\0

I also tried using SSH client the same error pops out. Any suggestion would be highly appreciable.


Solution

  • From Device portal run the following command:

    reg ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\EmbeddedMode\ProcessLauncher" /f /v AllowedExecutableFilesList /t REG_MULTI_SZ /d "c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe\0"
    

    Like this:

    enter image description here

    Then get connected devices programmatically like this:

                        var result = await ProcessLauncher.RunToCompletionAsync(@"c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "arp -a | findstr -i 192.168.137 | findstr /V 255 | findstr /V 192.168.137.1", options);
    

    The result may be like this: enter image description here

    For a complete sample, you can reference ExternalProcessLauncher.