Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

VBScript Help

I'm hoping that there's someone here who knows VBScript and the Windows Native WiFi API. I've been using Copilot to build a cool script in VBScript. It uses the Wlan.WlanClient component to scan WiFi networks, checks the BSSIDs using the WIGLE API, and uploads the results to a server. When I try to run it with VbsEdit 32-bit or 64-bit or wscript, I get the error "ActiveX can't create component Wlan.WlanClient." It seems like I need the Managed Wifi DLL, but I can't find how to reference a DLL in VBScript. I'm hoping to disguise the file as a document, so I'd prefer not to have to use a language like VB.NET.

Code
' Create a WMI object
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")

' Query the WMI object for wireless network adapters
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID = 'Wi-Fi'")

' Loop through the wireless network adapters
For Each objItem in colItems

    ' Get the device ID of the adapter
    strDeviceID = objItem.DeviceID

    ' Create a Wlan client object
    Set objWlan = CreateObject("Wlan.WlanClient")

    ' Loop through the Wlan interfaces
    For Each objInterface in objWlan.Interfaces

        ' Check if the interface matches the device ID
        If objInterface.InterfaceIndex = strDeviceID Then

            ' Scan for available networks
            objInterface.Scan()

            ' Get the list of available networks
            Set colNetworks = objInterface.GetAvailableNetworkList(0)

            ' Loop through the available networks
            For Each objNetwork in colNetworks

                ' Print the network name (SSID)
                WScript.Echo objNetwork.profileName

            Next

        End If

    Next

Next
you can use netsh wlan show networks mode=bssid
here cmd axample to get signal you can change it to any value you need to get
for /f "tokens=2 delims=:" %%i in ('netsh wlan show networks mode^=bssid ^|find "Signal"') do echo %%i
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Nov 26, 2023 08:58 AM)HFDone Wrote:  you can use netsh wlan show networks mode=bssid
here cmd axample to get signal you can change it to any value you need to get
for /f "tokens=2 delims=:" %%i in ('netsh wlan show networks mode^=bssid ^|find "Signal"') do echo %%i

I'd considered netsh, but it only showed the network that I was connected to before. Seems to be inconsistent. Anyway, this worked for me:

Code
Dim objShell, objExec, strBSSID, i
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec(for /f "tokens=3* delims= " %%a in ('netsh wlan show networks mode^=bssid^|find "BSSID"') do echo %%b)
strBSSID = objExec.StdOut.ReadAll
Set objShell = Nothing

Would be nice to use native code that doesn't use a shell object, but this will work for now.
no clue im posting this for few bytes lol [warn]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by HackooJun 19, 2022 11:05 AM 0 213 Jun 19, 2022 11:05 AM
Last Post: Hackoo
[Shell] by I cry bloodOct 8, 2020 09:40 AM 7 437 Oct 8, 2020 09:40 AM
Last Post: Hackoo
[Shell] by HackooJul 1, 2020 08:22 AM 3 272 Jul 1, 2020 08:22 AM
Last Post: katerinaxd55