Jump to content

Determine the current SSID


Recommended Posts

:) Success!!

Func _GetActiveSSID()
    Local $line, $foo = Run(@ComSpec&" /c "&'netsh wlan show int', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) 
    
    While @OSVersion = "WIN_VISTA"
        $line = StringStripWS(StdoutRead($foo, "peek=True"), 4)
        If @error Then ExitLoop
        If StringInStr($line, "SSID") Then
            $line = StringTrimLeft($line, StringInStr($line, "SSID")+6)
            Return (StringTrimRight($line, StringLen($line)-StringInStr($line, "BSSID")+2))
        ElseIf StringInStr($line, "disconnected") Then
            Return("None")
        EndIf
    Wend    ;<== While @OSVersion = "WIN_VISTA"
EndFunc     ;<== _GetActiveSSID

This works for me!! :P I am gonna try an XP version of this then add it when I am sure it works. Thanks for all the help guys!

Edited by Shalm
Link to comment
Share on other sites

  • 2 months later...

Hi ResNullius,

I have tried your code on xp worked fine on one box and didn't work on another XP box. Need to start WMI service before we use this code?. I have tried that too some it is not working on few XP boxes. Also wether WLAN is working on those boxes, but i didn't find WLAN also. If any one have any idea, Pls share with me.

Func _GetActiveSSIDXP()

Local $SSID = ""

$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\wmi")

$objMSNdis_80211_ServiceSetIdentifierSet = $objWMIService.ExecQuery("Select * from MSNdis_80211_ServiceSetIdentifier Where active=true")

For $objMSNdis_80211_ServiceSetIdentifier In $objMSNdis_80211_ServiceSetIdentifierSet

$ID = ""

For $i = 0 To $objMSNdis_80211_ServiceSetIdentifier.Ndis80211SsId(0)

$ID = $ID & Chr($objMSNdis_80211_ServiceSetIdentifier.Ndis80211SsId($i + 4))

Next

$SSID = $ID

Next

Return $SSID

EndFunc ;==>_GetActiveSSIDXP

Link to comment
Share on other sites

Hi ResNullius,

I have tried your code on xp worked fine on one box and didn't work on another XP box. Need to start WMI service before we use this code?. I have tried that too some it is not working on few XP boxes. Also wether WLAN is working on those boxes, but i didn't find WLAN also. If any one have any idea, Pls share with me.

Func _GetActiveSSIDXP()

Local $SSID = ""

$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\wmi")

$objMSNdis_80211_ServiceSetIdentifierSet = $objWMIService.ExecQuery("Select * from MSNdis_80211_ServiceSetIdentifier Where active=true")

For $objMSNdis_80211_ServiceSetIdentifier In $objMSNdis_80211_ServiceSetIdentifierSet

$ID = ""

For $i = 0 To $objMSNdis_80211_ServiceSetIdentifier.Ndis80211SsId(0)

$ID = $ID & Chr($objMSNdis_80211_ServiceSetIdentifier.Ndis80211SsId($i + 4))

Next

$SSID = $ID

Next

Return $SSID

EndFunc ;==>_GetActiveSSIDXP

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...