9 Replies - 668 Views - Last Post: 22 May 2020 - 08:31 AM Rate Topic: -----

#1 albert003   User is offline

  • D.I.C Addict

Reputation: 38
  • View blog
  • Posts: 866
  • Joined: 15-December 14

Program to detect wifi and show who is on the network

Posted 01 May 2020 - 01:51 PM

Doing some bartering with my neioghbour during this pandemic and she requested a program to be able to continue her aerobics classes with her clients online. Mary isn't tech savvy and is always complaining about problems she has with her computer when she does her aerobics class online. I took down notes and began to make the program to help her. She wanted a computer to tell her whether shes online, who is on her wifi (She has the cheapest Internet available from her cable company), Show the wifi signal strength and the name of the wifi shes using. Once this pandemic is over she will go back to the wifi at the studio and she needs these features.

The problem I am having is that how who is on the wifi shes using. I know I can use in cmd (In cmd I type netsh wlan show profiles) and when I write the code in console I can get it to work. My problem is that I can't seem to figure out why I can't get it to work when I make it as a gui. I get the following errors
1. The cmd window opens for a moment then closes
2. In textbox it shows the message "The following command was not found: netsh wlan show profiles"

I looked online for information and came up empty handed. Below is the way I am trying to figure it out, if someone knows a better method or suggestion I am open to any ideas, suggestions and help.

This is the program so far.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.NetworkInformation;

namespace lost_and_found
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void brnshowwifi_Click(object sender, EventArgs e)
        {//This will show if computer is on the Internet
            bool Connection = NetworkInterface.GetIsNetworkAvailable();
            if (Connection == true)
            {
                string yes = "Connected to the Internet";
                textBox1.Text = yes.ToString();
            }
            else
            {
                string nope = "Not connected to the Internet";
                textBox1.Text = nope.ToString();
            }
                
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //will show who is on the wifi network
            System.Diagnostics.Process pro = new System.Diagnostics.Process();
            pro.StartInfo.FileName = "netsh.exe";
            pro.StartInfo.Arguments = "netsh wlan show profiles";
            pro.StartInfo.UseShellExecute = false;
            pro.StartInfo.RedirectStandardOutput = true;
            pro.Start();
            textBox1.Text = pro.StandardOutput.ReadToEnd();

        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }


    }
}



Is This A Good Question/Topic? 0
  • +

Replies To: Program to detect wifi and show who is on the network

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15728
  • View blog
  • Posts: 63,014
  • Joined: 12-June 08

Re: Program to detect wifi and show who is on the network

Posted 01 May 2020 - 02:26 PM

41	            pro.StartInfo.Arguments = "netsh wlan show profiles";

Pretty sure 'netsh ' isn't needed as an argument to feed into netsh.exe.

May also want to chuck in eventually.

    p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

Was This Post Helpful? 0
  • +
  • -

#3 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7391
  • View blog
  • Posts: 24,952
  • Joined: 05-May 12

Re: Program to detect wifi and show who is on the network

Posted 01 May 2020 - 08:24 PM

I see that command there as telling you which WiFi network you are connected to, but I don't see how that will tell you who else is also connected.

I suspect discovering who else is also on the same WiFi network as you will require some port scanning, or packet sniffing, unless you can query the DHCP and/or DNS server to ask what IP addresses have been given out to your current network.
Was This Post Helpful? 0
  • +
  • -

#4 albert003   User is offline

  • D.I.C Addict

Reputation: 38
  • View blog
  • Posts: 866
  • Joined: 15-December 14

Re: Program to detect wifi and show who is on the network

Posted 01 May 2020 - 08:55 PM

modi123_1
So I removed "netsh" from the argument and added the line you suggested and now I get on textbox this message.
Profiles on interface Wi-Fi:

Group policy profiles (read only)
---------------------------------
<None>

Skydiver
I h9onestly thought it would be similar to cmd. I know I can type in cmd "netsh wlan show profiles". after I type that in it will show the IP Address of the computers and cell phones on my network. I was able to figure out how to do it in C++ doing it this way, but I wanted to try and figure it out in C#.
This is how I did it in C++ just using a command in cmd and not worrying about querry the DHCP or DNS server. I was hoping I could find a similar way to do it in C#.

void ListOnNetwork()
{
    system("netsh wlan show profiles");//shows all networks
    std::cout << std::endl;
}


Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7391
  • View blog
  • Posts: 24,952
  • Joined: 05-May 12

Re: Program to detect wifi and show who is on the network

Posted 02 May 2020 - 09:41 AM

Yes, it would be pretty much the same as your C++ code. The C system() library call is the same as using the .NET Framework Process.Start() with the Microsoft C library doing some pre-parsing to separate the first part as the executable, and the rest as the parameters so that things can be passed to the Win32 API ShellExecuteEx(). Process.Start() also calls ShellExecuteEx().
Was This Post Helpful? 0
  • +
  • -

#6 Radius Nightly   User is offline

  • D.I.C Regular

Reputation: 53
  • View blog
  • Posts: 357
  • Joined: 07-May 15

Re: Program to detect wifi and show who is on the network

Posted 02 May 2020 - 10:28 AM

She could use some phone app. NirSoft already made couple of applications for that, such as WifiChannelMonitor and WhoIsConnectedSniffer. She can also access the router and see statistics about connected devices.

This post has been edited by Radius Nightly: 02 May 2020 - 10:30 AM

Was This Post Helpful? 0
  • +
  • -

#7 albert003   User is offline

  • D.I.C Addict

Reputation: 38
  • View blog
  • Posts: 866
  • Joined: 15-December 14

Re: Program to detect wifi and show who is on the network

Posted 02 May 2020 - 10:26 PM

Radius Nightly
I use Advanced IP Scanner to find my PI's IP address when I work on programs specifically on the pi. I was hoping to create a similar program in C#.

Skydiver
Which was what I was trying to do. You actually gave me an idea and I will try it tomorrow.
Was This Post Helpful? 0
  • +
  • -

#8 albert003   User is offline

  • D.I.C Addict

Reputation: 38
  • View blog
  • Posts: 866
  • Joined: 15-December 14

Re: Program to detect wifi and show who is on the network

Posted 04 May 2020 - 09:32 PM

Ok, my idea didn't pan out but I found a tutorial to find the local available networks. Now I wanted to make it fancy for Mary and use a metroprogressbar to show the strength of the Internet. I know I can go to view, server explorer and then click on my computers name. Then it will display all of the menus visual studio has available. My question is it possible to do that with ssid? I looked on the menu as well as looked online and couldn't find a way to make a progressbar for the ssid strength.
Was This Post Helpful? 0
  • +
  • -

#9 Radius Nightly   User is offline

  • D.I.C Regular

Reputation: 53
  • View blog
  • Posts: 357
  • Joined: 07-May 15

Re: Program to detect wifi and show who is on the network

Posted 05 May 2020 - 02:23 AM

Maybe because strength are not in percentage. It can be in RSSI or dBm. Both are negative number, both works as closer to 0 means better. On top of that different manufacturers use different strength value range, for example RSSI works in values between 0-255, but Cisco uses 0-100, and Atheros use 0-60. Whatever you choose, you have to transform it into percentage, so dBm may be easier option.

BTW SSID doesnt mean much, because different MACs, on different channels and frequencies can all have same SSID, and can be used to crack the WiFi, try to hold on MAC, or frequency and channel.

This post has been edited by Radius Nightly: 05 May 2020 - 02:30 AM

Was This Post Helpful? 0
  • +
  • -

#10 albert003   User is offline

  • D.I.C Addict

Reputation: 38
  • View blog
  • Posts: 866
  • Joined: 15-December 14

Re: Program to detect wifi and show who is on the network

Posted 22 May 2020 - 08:31 AM

I tried to make it work and just couldn't figure it out. I found a different way to make it work by showing the name of the network as well as the strength in a textbox.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1