Page 1 of 1 1
Topic Options
#187857 - 2008-05-26 06:53 AM Get installed SSID's for a wireless NIC
lukeod Offline
Getting the hang of it

Registered: 2008-01-11
Posts: 70
Loc: Australia
Hey all,

Does anyone know a way of getting installed SSID's of a computer? I'd have thaught that WMI or COM would have a way. I did some googling and it may also be possible to get information programatically from windows zero config service, however i wouldn't know where to start for doing that.


Thanks

Luke

Top
#187858 - 2008-05-26 06:59 AM Re: Get installed SSID's for a wireless NIC [Re: lukeod]
lukeod Offline
Getting the hang of it

Registered: 2008-01-11
Posts: 70
Loc: Australia
Hmm i found this, although it does not look like a valid WMI class, could not find in Kixomatic \:\(

http://www.dotnet247.com/247reference/msgs/43/217642.aspx

Top
#187859 - 2008-05-26 07:59 AM Re: Get installed SSID's for a wireless NIC [Re: lukeod]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4384
Loc: USA
I found this...
http://msdn.microsoft.com/en-us/library/ms799402.aspx

...but have yet to find a working example (found some examples that didn't seem to work under vista)

Top
#187860 - 2008-05-26 08:38 AM Re: Get installed SSID's for a wireless NIC [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4384
Loc: USA
With a little cleanup of the output, this will give you the SSID.

netsh wlan profiles interface="Wireless Network Connection"

May still be a better way.

Top
#187861 - 2008-05-26 08:45 AM Re: Get installed SSID's for a wireless NIC [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4384
Loc: USA
This one gives more info...

netsh wlan show interfaces

Top
#187862 - 2008-05-26 08:56 AM Re: Get installed SSID's for a wireless NIC [Re: Allen]
lukeod Offline
Getting the hang of it

Registered: 2008-01-11
Posts: 70
Loc: Australia
Thanks for the posts thus far Allen. The problem is that the wlan subsection of netsh is new to vista, and there does not appear to be a way of getting the SSID from plain old command prompt in XP \:\(

However!!! i think i'm on to somthing with WMI. Using the Query:

 Code:
RedirectOutput('c:\scripts\output.txt',1)
Break On
$strComputer = "."
$objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\wmi")
$colItems = $objWMIService.ExecQuery("Select * from MSNdis_80211_ServiceSetIdentifier",,48)
?
For Each $objItem in $colItems
"********************"?
'has :' + UBound($objItem.Ndis80211SsId) + ' elements' ?
'The Array when Joined is (' + Join($objItem.Ndis80211SsId,',') + ')' ??
Next



it returns a 32 element array, containing a decimal ascii. For example it could output:

83, 111, 109, 101, 83, 83, 73, 68

Using a Ascii decimal to Ascii converter like http://www.vortex.prodigynet.co.uk/misc/ascii_conv.html, it spits out the correct SSID!!!!!

All i now need is a method of converting decimal ascii to ascii in kix =D

Cheers

Luke

Top
#187863 - 2008-05-26 09:02 AM Re: Get installed SSID's for a wireless NIC [Re: lukeod]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4384
Loc: USA
Damn Vista... your script, like all the others I was finding outputs nothing.
Top
#187864 - 2008-05-26 09:07 AM Re: Get installed SSID's for a wireless NIC [Re: Allen]
lukeod Offline
Getting the hang of it

Registered: 2008-01-11
Posts: 70
Loc: Australia
Hmm well that's no good \:\(

Do you know a way of converting Ascii decimal to plain old ascii? i found a script somewhere a while back written in kix to go from ascii --> ascii decimal, but searching on boards over last 15 mins aint showing much.

Top
#187865 - 2008-05-26 09:25 AM Re: Get installed SSID's for a wireless NIC [Re: lukeod]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4384
Loc: USA
Do you mean like...

 Code:
break on
$array=83, 111, 109, 101, 83, 83, 73, 68
for each $num in $array
  $output=$output+chr($num)
next

? $output


SomeSSID

Top
#187866 - 2008-05-26 09:29 AM Re: Get installed SSID's for a wireless NIC [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4384
Loc: USA
By the way, I read that Vista depreciated the WMI Driver Extension Services, which is why it does not work.
Top
#187867 - 2008-05-26 10:25 AM Re: Get installed SSID's for a wireless NIC [Re: Allen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
As Allen says, the interface will not work with Vista, but if you only need it for pre-Vista OS:

$strComputer = "."
$objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\wmi")
$colItems = $objWMIService.ExecQuery("Select * from MSNdis_80211_ServiceSetIdentifier",,48)
For Each $objItem in $colItems
$objItem.instanceName+" SSID: '"+funByteArray2String($objItem.Ndis80211SsId)+"'"+@CRLF
Next


Function funByteArray2String($ab)
$funBtyeArray2String=""
For Each $b in $AB
If CInt($b)>=32 AND CInt($b<=127)
$funByteArray2String=$funByteArray2String+CHR($b)
EndIf
Next
Exit 0
EndFunction



Important note!
The other thing you need to be aware of is that the data returned is a "byte array", and KiXtart does not support this data type although in this case the code does work.

The first four elements of the array appear to be the SSID string length so you could code a more complex array-to-string converter but as long as your SSIDs are short and contain only typeable 7-bit ASCII characters you can get away with the function as presented.

Top
#187872 - 2008-05-27 12:44 AM Re: Get installed SSID's for a wireless NIC [Re: Richard H.]
lukeod Offline
Getting the hang of it

Registered: 2008-01-11
Posts: 70
Loc: Australia
Tyvm for the code guys, it seems to work well.

I can now get the current connected SSID of the wireless nic, which is sort of what i am after. The problem is it only returns the connected SSID, not list all saved SSID's which would be ideal. It's basically run during logon to check that laptops have our ssid installed, and if not it attempts to add it using another script.

I'll have to keep playing with some of those WMI classes.

Top
#187874 - 2008-05-27 12:53 AM Re: Get installed SSID's for a wireless NIC [Re: lukeod]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Getting a laptop to connect wirelessly before logon takes an extraordinary effort. Assuming a traditional logon script, how do you assume a client to possibly connect to other than your ssid before logon?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#187878 - 2008-05-27 04:44 AM Re: Get installed SSID's for a wireless NIC [Re: Les]
lukeod Offline
Getting the hang of it

Registered: 2008-01-11
Posts: 70
Loc: Australia
Well the purpose of the script is to check that the ssid has been configured for that laptop, if not, add it. Otherwise if a laptop were to have the wireless nic disabled via the switch at the front and plugged into ethernet, my script so far would not detect the SSID has been configured (if it has been) and would try and install the ssid again.
Top
#187883 - 2008-05-27 02:41 PM Re: Get installed SSID's for a wireless NIC [Re: lukeod]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
Try this, it works for me. Anyone want to try with Vista? It would be useful to get some feedback.


Break ON


$sKey="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WZCSVC\Parameters\Interfaces"
$iIdx1=0
$sInt=EnumKey($sKey,$iIdx1)
While Not @ERROR
$iIdx2=0
$sNet=EnumValue($sKey+"\"+$sInt,$iIdx2)
While Not @ERROR
If InStr($sNet,"Static#")=1
$sSSIDRaw=ReadValue($sKey+"\"+$sInt,$sNet)
$iSSIDLen=Execute("Exit &"+SubStr($sSSIDRaw,33,2))
$sSSID=""
$sSSIDRaw=SubStr($sSSIDRaw,41)
While $iSSIDLen
$sSSID=$sSSID+Chr(Execute("Exit &"+Left($sSSIDRaw,2)))
$sSSIDRaw=SubStr($sSSIDRaw,3)
$iSSIDLen=$iSSIDLen-1
Loop
"Interface: "+$sInt+", Network: "+$sNet+", SSID: "+$sSSID+@CRLF
EndIf
$iIdx2=$iIdx2+1
$sNet=EnumValue($sKey+"\"+$sInt,$iIdx2)
Loop
$iIdx1=$iIdx1+1
$sInt=EnumKey($sKey,$iIdx1)
Loop


Top
#187887 - 2008-05-27 04:08 PM Re: Get installed SSID's for a wireless NIC [Re: Richard H.]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4384
Loc: USA
Well, I would except I'm in the process of wipping my Laptop with Vista on it. Boy has this been fun. Vista does something to the drive, and makes XP have a fit trying to install. The only thing I have found to work so far, is to slipstream SP3 on the Install Disk, and now (4 F'ing hours later) it appears to be installing. Holding my breath
Top
#187903 - 2008-05-28 12:55 AM Re: Get installed SSID's for a wireless NIC [Re: Allen]
lukeod Offline
Getting the hang of it

Registered: 2008-01-11
Posts: 70
Loc: Australia
Awesome, thanks mate. That works perfectly.
Top
#187905 - 2008-05-28 03:23 AM Re: Get installed SSID's for a wireless NIC [Re: lukeod]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
It doesn't work for me on XP using Intel PROSet.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#187910 - 2008-05-28 09:43 AM Re: Get installed SSID's for a wireless NIC [Re: Les]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
It's entirely possible that the values are proprietary.

The key is (I think) for the vanilla Wireless Zero Configuration service, so I guess if you are using a different tool to manage the wireless then the data may be stored elsewhere.

Also I should have mentioned that the code picks up pre-configured networks only by design - if you are simply roaming then it won't return found SSIDs.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 177 anonymous users online.
Newest Members
dboozcruise, 2786707460, Marc57, EricMyers, siddharthinfosy
17519 Registered Users

Generated in 0.082 seconds in which 0.029 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org