PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] How to find my current SSID name.-VBForums
Results 1 to 18 of 18

Thread: [RESOLVED] How to find my current SSID name.

  1. #1

    Thread Starter
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,810

    Resolved [RESOLVED] How to find my current SSID name.

    Hi,

    I've been searching for a method to find my current SSID name, there are many such questions on the web, a good few of 'em ask how to do it with vb.NET, I've not found a working answer yet.

    I did find one using C# and converting that to a vb.NET subroutine only produced a long string of numbers, I'm looking for an actual name.

    I tried to find out about 'WLAN' but MSDB is less than helpful.

    A pointer to the solution would be appreciated.


    Poppa.
    Along with the sunshine there has to be a little rain sometime.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,718

    Re: How to find my current SSID name.

    Quote Originally Posted by Poppa Mintin View Post
    I did find one using C# and converting that to a vb.NET subroutine only produced a long string of numbers
    Did the C# code produce the expected result? If so then the issue is in your conversion, so that's what you should address.

  3. #3
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    640

    Re: How to find my current SSID name.

    Did your Google search come up with this?

    https://stackoverflow.com/questions/...ramework-4-5-2

    I haven't tried it but it looks like a good solution.

    EIDT: Just tried the code from stackoverflow and it works a treat. Doesn't work on a machine with no WiFi connection (duh!). I haven't done much with nuget and I couldn't see a "browse" option so I typed Install-Package ManagedWifi at the Package Manager Console prompt (using VS2017 here).
    Last edited by paulg4ije; Mar 25th, 2020 at 12:00 PM.

  4. #4

    Thread Starter
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,810

    Re: How to find my current SSID name.

    Quote Originally Posted by jmcilhinney View Post
    Did the C# code produce the expected result? If so then the issue is in your conversion, so that's what you should address.
    I'm looking for the Name of my SSID, not a string of numbers. I found the code which produced the string of numbers early in my search but because didn't give me a name I deleted it, expecting to find something better, but now that I come to address your answer I can't find that web page.
    There are now several dozen of visited pages making the search for that code like trying to find that proverbial needle.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  5. #5
    Lively Member
    Join Date
    Jun 2019
    Posts
    102

    Re: How to find my current SSID name.

    Poppa, the link paulg4ije provided works and returns string.

  6. #6

    Thread Starter
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,810

    Re: How to find my current SSID name.

    Thanks for the reply Paul,

    I keep finding that item cropping up all over the web. I'm trying to write a small utility that I can use to investigate a problem, I want to be able to use the utility in several machines without having to install anything else in those machines and it seems to me that 'The Package' would have to be installed in order for it to work.

    Poppa
    Along with the sunshine there has to be a little rain sometime.

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,718

    Re: How to find my current SSID name.

    That managedwifi package is open source, so you could examine it and possibly incorporate the required parts of the code in your own project.

    https://www.nuget.org/packages/managedwifi
    https://archive.codeplex.com/?p=managedwifi

  8. #8
    Lively Member
    Join Date
    Jun 2019
    Posts
    102

    Re: How to find my current SSID name.

    This is the test I did yesterday from the link paulg4ije provided with some changes to work as console app.
    VB.NET Code:
    1. Imports System.Text
    2. Imports NativeWifi
    3.  
    4. Module Module1
    5.     Sub Main()
    6.         Dim wlan = New WlanClient()
    7.         Dim connectedSsids = New List(Of String)
    8.  
    9.         For Each wlanInterface As WlanClient.WlanInterface In wlan.Interfaces
    10.             Dim ssid As Wlan.Dot11Ssid = wlanInterface.CurrentConnection.wlanAssociationAttributes.dot11Ssid
    11.             connectedSsids.Add(New [String](Encoding.ASCII.GetChars(ssid.SSID, 0, CInt(ssid.SSIDLength))))
    12.  
    13.             For Each item As String In connectedSsids
    14.                 Console.WriteLine(item)
    15.             Next
    16.         Next
    17.         Console.ReadLine()
    18.     End Sub
    19. End Module

  9. #9

    Thread Starter
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,810

    Re: How to find my current SSID name.

    Thanks guys,

    I've tried to implement paulg4ije's method a few times but I don't get to the Nuget site, I don't know why.
    I'd like to try paulg4ije's method of typing 'Install-Package ManagedWifi at the Package Manager Console prompt', but I can't find the Package Manager Console prompt.

    That'll be my fault because I can't remember how to make a Console application. I can't believe the method can't be adapted to run in a Windows app.


    Poppa
    Last edited by Poppa Mintin; Mar 26th, 2020 at 07:03 AM. Reason: Typo
    Along with the sunshine there has to be a little rain sometime.

  10. #10
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    640

    Re: How to find my current SSID name.

    In VS2017 go to Tools > NuGet Package Manager > Package Manager Console

    At the PM> prompt type Install-Package ManagedWifi

    At least, that's what worked for me. I made a Windows Form app from that Stackoverflow example.

  11. #11

    Thread Starter
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,810

    Re: How to find my current SSID name.

    Thanks Paul,

    That was easy !

    For my record my 'VB Snippets' folder now has this .txt file:


    To read the SSID for this computer:

    1: In VS go to Tools > NuGet Package Manager > Package Manager Console

    2: At the PM> prompt type "Install-Package ManagedWifi" without quotes.

    3: In Form1 add:
    Imports System.Text
    Imports NativeWifi

    4: Add subroutine.
    Private Sub Find_SSID()
    Dim wlan = New WlanClient()
    Dim connectedSsids = New List(Of String)

    Label8.Text = ""
    For Each wlanInterface As WlanClient.WlanInterface In wlan.Interfaces
    Dim ssid As Wlan.Dot11Ssid = wlanInterface.CurrentConnection.wlanAssociationAttributes.dot11Ssid
    connectedSsids.Add(New [String](Encoding.ASCII.GetChars(ssid.SSID, 0, CInt(ssid.SSIDLength))))
    For Each item As String In connectedSsids
    Label8.Text += item
    Next
    Next
    End Sub ' Get the SSID for this connection.

    5: Change 'Label8' to whatever.

    All done.
    Just for information this is just the same in VS 2019.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  12. #12

    Thread Starter
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,810

    Re: [RESOLVED] How to find my current SSID name.

    Oh bother !

    This works fine on the machine on which it's designed...
    But not on a machine to which it's been exported. Error: Can't find ManagedWifi.dll.

    I can't find how to embed the ManagedWifi.dll in the .exe file. I have CopyLocal set to true, hasn't helped.
    The dll is in Resources and set as Embedded Resource, that hasn't helped either.

    Don't know what else to do.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  13. #13

    Thread Starter
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,810

    Re: [RESOLVED] How to find my current SSID name.

    Hi,

    I found this URL:Which seems to be what I'm looking for, I've followed the instructions and my application still works on my laptop but not elsewhere.
    Using a breakpoint I find that the Sub AppStart runs, apparently correctly, but nothing calls Function ResolveAssemblies.

    I can't see how to do that. I don't believe it's covered in the article. The note concerning the Output path suggests switching the CopyLocal to False, I tried that but then the application didn't run at all... "Can't find ManagedWifi.dll".


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  14. #14
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    640

    Re: [RESOLVED] How to find my current SSID name.

    Quick and dirty might be to copy the Managedwifi.dll to the same folder as your executable. The dll will be in your bin folder.

  15. #15
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,718

    Re: [RESOLVED] How to find my current SSID name.

    Quote Originally Posted by Poppa Mintin View Post
    I can't find how to embed the ManagedWifi.dll in the .exe file.
    That's because you don't. If you're desperate to do so then you may be able to use ILMerge for the task, but that's not something I've tried in a long time and I never did so successfully anyway.
    Quote Originally Posted by Poppa Mintin View Post
    I have CopyLocal set to true, hasn't helped.
    It has, because it's done what it's supposed to. It has copied the DLL into your output folder along with your EXE when you build. You are supposed to then deploy the DLL with the EXE. That's the point of it being there. You only don't do that if you know that a required DLL will be independently installed on the target machine(s).
    Quote Originally Posted by Poppa Mintin View Post
    The dll is in Resources and set as Embedded Resource, that hasn't helped either.
    Of course it hasn't. You would have to write code to extract the data and write it to a file, but many systems will flag that as malware-like activity and block it.

  16. #16
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,718

    Re: [RESOLVED] How to find my current SSID name.

    Quote Originally Posted by paulg4ije View Post
    Quick and dirty might be to copy the Managedwifi.dll to the same folder as your executable. The dll will be in your bin folder.
    That's not a quick and dirty solution. That is the proper solution. That's what many millions of programs do every day.

  17. #17

    Thread Starter
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,810

    Re: [RESOLVED] How to find my current SSID name.

    Quote Originally Posted by jmcilhinney View Post
    That's not a quick and dirty solution. That is the proper solution. That's what many millions of programs do every day.
    I didn't want to do that because I consider it makes exporting more complicated, but if it's the correct way to do it... so be it.

    Poppa.
    Along with the sunshine there has to be a little rain sometime.

  18. #18

    Thread Starter
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,810

    Re: [RESOLVED] How to find my current SSID name.

    Ok... That works, I don't like doing it that way though.

    The annoying thing is that it wasn't really necessary, I wanted a little tool to check if two or more computers were on the same network or not. I set out four results, connected: Public IP Address, Private IP Address, Network Name and Computer Name.

    The two IPs and Machine Name were simple, only the Network Name was (obviously) the sticky bit.
    Sadly the Network Name wasn't really necessary... If the Public Address on both (all) machines are the same then they're on the same network, we don't actually need the network name. The only advantage would be that if they are not the same, we'd know which networks the machines are connected to.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width