Jump to content
Sign in to follow this  
MattyD

Native Wifi Functions

Recommended Posts

Is there an issue with this UDF in the latest version of autoit? I was using AutoIt v3.3.6.1 with my vistumbler application and noticed I was no longer getting APs when using native wifi. It seems like _Wlan_GetAvailableNetworkList was returning empty arrays (the array looked like it had 6 rows with no information).

I switched back to AutoIt v3.3.0.0 (which was the last version I had used) and now everything seems to be working properly.

Yeah, the issue is with a stringregexp in the bulidstructsrting function (internal). There are a few other things I want to fix up before officially posting the next version -mainly with everything else besides the actual UDF. I can send you a fix tonight when I get home...

A good idea would be to combine it with Google Maps and GPS

I'm confused... This UDF is intended for managing wireless connections. It cannot give any positional data.

Cheers,

Matt

Share this post


Link to post
Share on other sites

Bonjours je pense que vous aviez compris le fonctionnement de ce script pourriez vous m’aide svp,

car depuis 3 jours je cherche un script pour le déploiement du mon wifi sur xp sp3 mais je n’ai rien

compris sur tout ce qui à été écris ici j’ai 80 pc alors j’aimerais de l’aide svp

---------------------------------------------------------------------------------------------------

Hi I think you understood the operation of this script could you please help me,

because for three days I want a script to deploy the wifi on my xp sp3 but I did not

understand everything that was to write I have 80 pc here so I'd like to help please

Share this post


Link to post
Share on other sites

Hi Niangui,

I'm happy to help out where i can. Could you start a new thread under "General help and Support" with the code you are having trouble with...

Thanks,

Matt

Share this post


Link to post
Share on other sites

Thank you Matt for your quick response,

I just downloaded AutoIt but I do not know how it works is that you could not but make a quick tutorial with the script please Fi deployment on Windows XP sp3.

Even if you could help me thank you

Niangui

Share this post


Link to post
Share on other sites

Hey folks,

It is time to say goodbye to version 3 methinks, the UDF is absolutely crying out for an overhaul.

If there is anything else particularly bad though I may realease one more version 3 - just fixes.

Onward and upward! - Until then...

Version 3.3 Release

Fixed

_Wlan_GetAvailableNetworkList(), _Wlan_EnumInterfaces() and _Wlan_GetProfileList() return empty arrays when more than one item is found under later versions of AutoIt.

_Wlan_Connect() and _Wlan_ConnectWait() do not connect to ad hoc profiles.

_Wlan_GetAvailableNetworkList() flags are not properly implemented.

Select card does not work in the sample.

The “Use Windows Login and Password” parameter does not work when setting PEAPMSCHAP profiles in the sample.

Added

Function _Wlan_SetProfileUserData()

Function _Wlan_SetProfileUserDataXML()

Function _Wlan_GenerateXMLUserData()

Simple .au3 sample file to cover the basics (version a and b )

Changed

If a default $pGUID value is set, _Wlan_ConnectWait(), _Wlan_ConnectWait() and _Wlan_WaitForDisconnect will only process messages relating to the default interface.

_Wlan_ConnectWait() will return an error if a disconnected code is processed after the connection process is deemed to be initiated (rather than timing out).

_Wlan_SetProfile() and _Wlan_GenerateProfileXML() now automatically determine if the key material is of type "Network Key" or "Pass Phrase".

Updated .au3 sample file (now Wifi Playpen)

Updated keywords, calltips and documentation files

Removed

Removed version b of .au3 sample file (now Wifi Playpen)

Removed installer (now external)

Thanks,

MattyD

Share this post


Link to post
Share on other sites

RLY kewl and useful, thank you so much!

Although there were some problem with Samplea (ur own functions called with wrong number of arguments...)

Share this post


Link to post
Share on other sites

Is there possible to import a XML profile that is not 'blob'? I'm trying to setup a automatic profile setup for our network (802.1x PEAP), and "The key is provided for me automaticly" is not a WPA2 option. Without this option checked, my profile is not exported with blob-configuration, and without blob, the _Wlan_SetProfile fails. Is there something I'm missing? Please help. Also _Wlan_SetProfile works like a charm on Vista and W7 as long as it's a XML with blob.

Second: Will there be a official support for Vista W7? Export XML from them does not come with blob, and the "The key is provided for me automaticly" option is only available in XP.

Thanks

Share this post


Link to post
Share on other sites

hey guys - I will try to clear a few things up.

there were some problem with Samplea (ur own functions called with wrong number of arguments...)

Whoops! that definately should not have gotten through. This is why you don't upload content on the same late night you finish it...

just change line 11 to: (included the wrong file)

#include "..\Wifi33a.au3"
and line 42 to: (obviously was using the version b syntax)

Local $sState = _Wlan_QueryInterface(2)

Is it possible to import a XML profile that is not 'blob'?

Yes.

To clarify a bit... The blob is one element in a profile containing only the EAP (i.e PEAP or TLS) config data. The API provides you with an option to use plain text instead of the blob - but only for importing. There is a bug in XP SP3 however - you can only use the plain text option if you download that hotfix mentioned in the documentation.

I'm trying to setup a automatic profile setup for our network (802.1x PEAP), and "The key is provided for me automaticly" is not a WPA2 option.

The "The key is provided..." checkbox is just microsoft lay-speak for "use 802.1x authentication". WPA and WPA2 (without the PSK) has to use 802.1x for authentication; thus the box for all intents and purposes is ticked. As far as I remember it is perfectly feasible to use both 802.1x and a pre shared key, though it's self defeating. So.. I would not be supprised if MS took away the checkbox for these configurations. For the record I think the API will accept a profile with both settings - even if you can't manually set one up through the GUI.

Here is where you may be falling down... There is an authentication tab when you create a profile in XP where you can set the parameters for 802.1x. Altenatively you can just use _Wlan_GenerateXMLProfile(). If you are still having problems, have a look at the profile samples in the PDF and check out the Playpen included in the package.

Will there be a official support for Vista W7?

yes - all in good time. It will be in the next version but its still a long way off. In the mean time check out the "netsh wlan" functions from the command prompt.

hope this helps,

Matt

Share this post


Link to post
Share on other sites

Hello,

First may I thank you for the code and effort that you have put into this useful tool.

I'm new to AutoIT and not an experienced user when it comes to programming, but I'm trying to get your tool to work/run. I seen you have two versions (A and ;), and I have read the PDF support file included in v3.3 but still don't know exactly how to set it up.

I'm doing all my tests on a Windows XP SP3 (first thing I did was install the KB) and I compiled your Wifi tool but when I try to run it...it does nothing, I even tried to call it via the CMD line but I guess there's something missing...

Please would you point me in the right direction, I'm kinda lost here.

Thanks,

~Locobans

Share this post


Link to post
Share on other sites

Hey Locobans,

Welcome to the forums! and thankyou.

This question should really be posted in the "general help and support" section... If you would like to continue on after this could you please start up a thread there.

The UDF will not do anything by itself. you will need to use an "include" directive to make the functions available to your script. so your first script would look something like this:

#include <wifi33a.au3> ;This directive inserts the contents of wifi33a.au3 here (Exposes the Wlan functions to the rest of your script)
#include <array.au3>
;If a file is not in AutoIt's Include folder (i.e. C:\Program Files\AutoIt3\Include)
;then the syntax would look something like:
;#include "C:\blahblahblah\wifi33a.au3"  

$avInterfaces = _Wlan_StartSession()
_ArrayDisplay($avInterfaces)

If you have the script open in scite just press F5. Generally speaking there is no need to compile until you've finished.

This elementry stuff dude, I suggest looking at the AutoIt help file and looking at few general tutorials first - AutoIt 123 is a popular one round here. Can't walk before you crawl!

Good Luck,

Matt

Edited by MattyD

Share this post


Link to post
Share on other sites

Hey Locobans,

Welcome to the forums! and thankyou.

This question should really be posted in the "general help and support" section... If you would like to continue on after this could you please start up a thread there.

The UDF will not do anything by itself. you will need to use an "include" directive to make the functions available to your script. so your first script would look something like this:

#include <wifi33a.au3> ;This directive inserts the contents of wifi33a.au3 here (Exposes the Wlan functions to the rest of your script)
#include <array.au3>
;If a file is not in AutoIt's Include folder (i.e. C:\Program Files\AutoIt3\Include)
;then the syntax would look something like:
;#include "C:\blahblahblah\wifi33a.au3"  

$avInterfaces = _Wlan_StartSession()
_ArrayDisplay($avInterfaces)

If you have the script open in scite just press F5. Generally speaking there is no need to compile until you've finished.

This elementry stuff dude, I suggest looking at the AutoIt help file and looking at few general tutorials first - AutoIt 123 is a popular one round here. Can't walk before you crawl!

Good Luck,

Matt

Thanks a lot for replying bro...really appreciate it ;)

Yes, I kinda understand more now after some reading...here's how my script look like at the end...I made it do what I wanted it to do...

1. Shows the windows with the text "please wait" while the whole script is running.

2. Script runs at STARTUP so insert 35seconds delay to wait windows to load up completely.

3. Runs function to remove a wireless network profile.

4. Popup login client that we use that needs to be closed down before continuing.

5. With the help of tool "devcon" from Microsoft, I'm able to disable/enable the WiFi Card and by then having the connection repaired and connected to the other profile automatically.

It is kinda crappy code... but if you see, I used your old Wifi v2.2 functions.

Kinda new to AutoIt but so far like it very much.

~Locobans

#include "Native_Wifi_Func_V2_2.au3"

SplashTextOn("IT Department", "Please wait while your wireless is being configured.", 250, 80, -1, -1, 4, "", 14)
    sleep(35000)
    _DeleteWifi()
    sleep(5000)
    if WinExists("Cisco Clean Access Agent") then
        WinClose("Cisco Clean Access Agent")
    EndIf
    RunWait(@ComSpec & " /c " & "devcon disable *DEV_4236*") ; Disable the WiFi card
    sleep(10000)
    RunWait(@ComSpec & " /c " & "devcon enable *DEV_4236*") ; Enables the WiFi Card
    sleep(5000)
    
SplashOff()
MsgBox(0, "IT Department", "You can now login to the CSADMIN network")


;*********************************************************************************************
;************************************FUNCTIONS PART*******************************************
;*********************************************************************************************
Func _DeleteWifi()
    $SSID = "STUDENT_WIFI"      ; Enter wireless network name to be removed
    $hClientHandle = _Wlan_OpenHandle()
    $Enum = _Wlan_EnumInterfaces($hClientHandle)
    $pGUID = $Enum[0][0]
    $a_iCall = DllCall($WLANAPIDLL, "dword", "WlanDeleteProfile", "hwnd", $hClientHandle, "ptr", $pGUID, "wstr", $SSID, "ptr", 0)
EndFunc
    
#cs
**************************Function not used anymore**************************
Func _AddProfile()
    $XMLProfile = FileRead("C:\Program Files\Scripts\Profile.xml")      ; Name of the file containing the profile
    $hClientHandle = _Wlan_OpenHandle()
    $Enum = _Wlan_EnumInterfaces($hClientHandle)
    $pGUID = $Enum[0][0]

    $a_iCall = DllCall($WLANAPIDLL, "dword", "WlanSetProfile", "hwnd", $hClientHandle, "ptr", $pGUID, "dword", 0, "wstr", $XMLProfile, "ptr", 0, "int", 1, "ptr", 0, "dword*", 0)
    ConsoleWrite("Call Error: " & @error & @LF)
    ConsoleWrite(_Wlan_GetErrorMessage($a_iCall[0]))
EndFunc
#ce

Edit: It the code, you have an AddProfile function commented that I was using to SET A PROFILE already saved in a XML file with all proper configuration...read it couple of posts back in the post :)

Offtopic: can someone change my name to Locobans... I misspelled...

Edited by locoban

Share this post


Link to post
Share on other sites

First, thanks for the great code, it works well.

I have everything I need working except for one task - I wish to automatically enter user credentials into a PEAP connection on Windows 7.

I suspect there are two typos in the PDF on page 21, "Possible Values: PEAP-MSCHP" should read PEAP-MSCHAP according to Wifi33a.au3

I'm stuck on _Wlan_SetProfileUserData() and _Wlan_SetProfileUserDataXML() - No matter what I do, Windows always returns "The network connection profile is corrupted"

Reading the NativeWiFi syntax on MSDN here http://msdn.microsoft.com/en-us/library/ms706802%28VS.85%29.aspx, it says use these entries:

DWORD WlanSetProfileEapXmlUserData(

__in HANDLE hClientHandle,

__in const GUID *pInterfaceGuid,

__in LPCWSTR strProfileName,

__in DWORD dwFlags,

__in LPCWSTR strEapXmlUserData,

__reserved PVOID pReserved

);

The entry in Wifi33a, formatted for reading,

$a_iCall = DllCall($WLANAPIDLL, "dword", "WlanSetProfileEapXmlUserData", _
    "hwnd", $hClientHandle, _
    "ptr", $pGUID, _
    "wstr", $SSID, _
    "dword", 0, _
    "wstr", $UserData, _
    "ptr", 0)

The $UserData variable contains the XML. I tried using XML from http://msdn.microsoft.com/en-us/library/bb891979%28v=VS.85%29.aspx and using the generated XML from Wifi33a.au3, both return "The network connection profile is corrupted".

Retrieving the profile works, the correct XML is printed

#Include <GuiListView.au3>
#Include <wifi33a.au3>
#Include <array.au3>

$a = _Wlan_StartSession()
$hClientHandle = @extended
$pGUID = $a[0][0]
;_arraydisplay($a)

$b = _Wlan_GetAvailableNetworkList(0)
;_ArrayDisplay($b)

$c = _Wlan_GetProfile("uDev80211")
;_ArrayDisplay($c)

$d = _Wlan_GetProfileXML("uDev80211", $pGUID, $hClientHandle)
ConsoleWrite($d)

Using _Wlan_SetProfileUserData() returns the error "The network connection profile is corrupted"

#Include <GuiListView.au3>
#Include <wifi33a.au3>
#Include <array.au3>

$a = _Wlan_StartSession()
$hClientHandle = @extended
$pGUID = $a[0][0]
;_arraydisplay($a)

$b = _Wlan_GetAvailableNetworkList(0)
;_ArrayDisplay($b)

$c = _Wlan_GetProfile("uDev80211")
;_ArrayDisplay($c)

dim $da[4]
$da[0] = "PEAP-MSCHAP"  ; identifier
$da[1] = "dev"          ; domain name
$da[2] = "adm01"        ; user
$da[3] = "Querty!23"    ; password

$d = _Wlan_SetProfileUserData("uDev80211", $da, Default, Default)
ConsoleWrite($d)

Using the _Wlan_SetProfileUserDataXML also returns the same error:

#Include <GuiListView.au3>
#Include <wifi33a.au3>
#Include <array.au3>

$a = _Wlan_StartSession()
$hClientHandle = @extended
$pGUID = $a[0][0]
;_arraydisplay($a)

$b = _Wlan_GetAvailableNetworkList(0)
;_ArrayDisplay($b)

$c = _Wlan_GetProfile("uDev80211")
;_ArrayDisplay($c)

$d = _Wlan_SetProfileUserDataXML("uDev80211", "C:\peap.xml")
ConsoleWrite($d)

What am I doing wrong and can anyone provide any assistance?

Also, if anyone can answer this, how would I use WlanSetProfileEapUserData (http://msdn.microsoft.com/en-us/library/ms706797%28v=VS.85%29.aspx) - What does this mean:

pbEapUserData [in]

A pointer to the raw EAP data used to set the user credentials.

DWORD WlanSetProfileEapUserData(

__in HANDLE hClientHandle,

__in const GUID *pInterfaceGuid,

__in LPCWSTR strProfileName,

__in EAP_METHOD_TYPE eapType,

__in DWORD dwFlags,

__in DWORD dwEapUserDataSize,

__in const LPBYTE pbEapUserData,

__reserved PVOID pReserved

);

Thanks!

Share this post


Link to post
Share on other sites

Hey man,

There seems to be a mistake on line 534 of the UDF. ($pGUID and $hClientHandle are back to front.) It should be...

$Return = _Wlan_SetProfileUserDataXML($SSID, $Return, $pGUID, $hClientHandle)

With that fixed, this following code works on win7...

#RequireAdmin
#include <wifi33a.au3>
Local $asProfile[4][6]
$asProfile[0][0] = "Test(PEAP-MSCHAP)"
$asProfile[0][3] = "WPA2"
$asProfile[0][4] = "AES"
$asProfile[0][5] = "802.1x Enabled"
$asProfile[1][0] = "PEAP"
$asProfile[1][1] = "Fast Reconnect"
$asProfile[1][2] = "No Quarantine Checks"
$asProfile[1][3] = "Don't Require Cryptobinding"
$asProfile[2][0] = "Validate Certificate"
$asProfile[2][1] = "Don't Prompt User"
$asProfile[3][0] = "MSCHAP"
$asProfile[3][1] = "Don't Use Win Logon"

Local $asUserData[4]
$asUserData[0] = "PEAP-MSCHAP"
$asUserData[1] = "dev"
$asUserData[2] = "adm01"
$asUserData[3] = "Querty!23"

$sReturn = _Wlan_StartSession()
If @error Then _ReportError(@error, @extended, $sReturn, @ScriptLineNumber)

$sReturn = _Wlan_SetProfile($asProfile)
If @error Then _ReportError(@error, @extended, $sReturn, @ScriptLineNumber)

$sReturn = _Wlan_SetProfileUserData($asProfile[0][0], $asUserData)
If @error Then _ReportError(@error, @extended, $sReturn, @ScriptLineNumber)

Func _ReportError($iError, $iExtended, $sReturn, $iLine)
    MsgBox(0, "Error!", "Error @ln(" & $iLine & ") err[" & $iError & "] ext[" & $iExtended & "]" & @CRLF & $sReturn)
EndFunc

I suspect there are two typos in the PDF on page 21, "Possible Values: PEAP-MSCHP" should read PEAP-MSCHAP according to Wifi33a.au3

Correct. ;)

I tried using XML from http://msdn.microsoft.com/en-us/library/bb891979%28v=VS.85%29.aspx and using the generated XML from Wifi33a.au3, both return "The network connection profile is corrupted".

The sample XML from MSDN works fine here! Connection profiles have been known to actually corrupt. If deleting and recreating it doesn't help, could you shoot through the profile you are using?

What does this mean:

pbEapUserData [in]

I would say it is looking for a pointer to a blob. Unfortunately the XML will be much simpler :)

Thanks,

Matt

Edit - Corrected mistake in code.

Edited by MattyD

Share this post


Link to post
Share on other sites

I tried incorporating this into a program for XP that backs up the profiles and restores them. It looks like it can back the profiles up, but I noticed it's not the same when it comes to the password as it is in my Win7 exports (using netsh). Also when I import I use the ConsoleWrite and it says it's an invalid schema. This goes for the original XP profiles as well as the Win7 profiles. In the XML outputs, Win7 has a longer password than XP and Win7 also shows it as a "passPhrase" whereas XP has it as "networkKey".

Below are the 2 functions relating to backing up and restoring. Maybe I'm doing something wrong.

;~ =============================================================
Func BackupProfiles($osVersion, $user)
    If ($osVersion = "Win_7") Then
        ;Win7 code goes here
        If DirGetSize($user) < 0 Then
            DirCreate($user)
        EndIf
        RunWait("netsh wlan export profile folder=" & $user)
        Return -1
    ElseIf ($osVersion = "Win_XP") Then
        ;XP code goes here
        If DirGetSize($user) < 0 Then
            DirCreate($user)
        EndIf
        
        _Wlan_StartSession()
        Local $sProfile
        Local $asProfileList = _Wlan_GetProfileList(-1, -1)
        For $i = 0 To UBound($asProfileList) - 1
            $sProfile = _Wlan_GetProfileXML(-1, -1, $asProfileList[$i])
            FileWrite($user & "\Wireless Network Connection-" & $asProfileList[$i] & ".xml", $sProfile)
        Next
        _Wlan_EndSession(-1)
        
        Return -1
    EndIf
EndFunc ;==>RestoreProfiles

;~ =============================================================
Func RestoreProfiles($osVersion)
    If ($osVersion = "Win_7") Then
        ;Win7 code goes here
        Local $search, $file, $netsh
        $search = FileFindFirstFile($userName & "\*.xml")
        For $i = 1 to 200
            $file = FileFindNextFile($search)
            If @error Then ExitLoop
            $netsh = 'netsh wlan add profile filename="' & $userName & '\' & $file & '"'
            RunWait($netsh)
        Next
        FileClose($search)
        Return -1
    ElseIf ($osVersion = "Win_XP") Then
        ;XP code goes here
        
        _Wlan_StartSession()
        Local $sProfile, $asProfileList, $nextFile
        Local $firstProfile = FileFindFirstFile($userName & "\*.xml")
        FileOpen($firstProfile)
        For $i = 0 To $firstProfile + 1
            $nextFile = FileFindNextFile($firstProfile)
            FileOpen($nextFile)
            $sProfile = _Wlan_SetProfileXML(-1, -1, $nextFile)
            FileClose($nextFile)
            ConsoleWrite($sProfile & @CRLF)
        Next
        FileClose($firstProfile)
        _Wlan_EndSession(-1)
        
        Return 0
    EndIf
EndFunc ;==>RestoreProfiles

This is the Win7 XML:

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
    <name>SSIDNAME</name>
    <SSIDConfig>
        <SSID>
            <hex>SSIDHEX</hex>
            <name>SSIDNAME</name>
        </SSID>
        <nonBroadcast>false</nonBroadcast>
    </SSIDConfig>
    <connectionType>ESS</connectionType>
    <connectionMode>auto</connectionMode>
    <MSM>
        <security>
            <authEncryption>
                <authentication>WPA2PSK</authentication>
                <encryption>AES</encryption>
                <useOneX>false</useOneX>
            </authEncryption>
            <sharedKey>
                <keyType>passPhrase</keyType>
                <protected>true</protected>
                <keyMaterial>LongPasswordCodeHere</keyMaterial>
            </sharedKey>
        </security>
    </MSM>
</WLANProfile>

This is the XP XML:

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
    <name>SSIDNAME</name>
    <SSIDConfig>
        <SSID>
            <hex>SSIDHEX</hex>
            <name>SSIDNAME</name>
        </SSID>
    </SSIDConfig>
    <connectionType>ESS</connectionType>
    <MSM>
        <security>
            <authEncryption>
                <authentication>WPA2PSK</authentication>
                <encryption>AES</encryption>
                <useOneX>false</useOneX>
            </authEncryption>
            <sharedKey>
                <keyType>networkKey</keyType>
                <protected>false</protected>
                <keyMaterial>ShortPasswordCodeHere</keyMaterial>
            </sharedKey>
        </security>
    </MSM>
</WLANProfile>

Share this post


Link to post
Share on other sites

Hey Mate,

In the XML outputs, Win7 has a longer password than XP and Win7 also shows it as a "passPhrase" whereas XP has it as "networkKey".

The Vista/7 API will return an encrypted key unless the WLAN_PROFILE_GET_PLAINTEXT_KEY flag is present. Im guessing you'll have to do the equivalent with netsh to get that profile to work. The "network key" profile has just the hex representation of the password.

I'm assuming you are using version 3.3 of the UDF? This crude example imports a WPA2-PSK AES XML profile:

;This example is for XP!
#include "Wifi33b.au3"

$Return = _Wlan_StartSession()
If @error Then ConsoleWrite("!Err[" & @error & "] Ext[" & @extended & "] - " & $Return)

Local $Profile[9] ;Just used to generate a valid profile
$Profile[0] = "Test WPA2"
$Profile[3] = "WPA2-PSK"
$Profile[4] = "AES"
$Profile[7] = "TestPassword"

$ProfileXML = _Wlan_GenerateXMLProfile($Profile)
ConsoleWrite("-The profile to import:" & @CRLF & $ProfileXML & @CRLF)

$Return = _Wlan_SetProfileXML(-1, -1, $ProfileXML)
If @error Then ConsoleWrite("!Err[" & @error & "] Ext[" & @extended & "] - " & $Return)

$ProfileXML = _Wlan_GetProfileXML(-1, -1, $Profile[0])
If @error Then ConsoleWrite("!Err[" & @error & "] Ext[" & @extended & "] - " & $ProfileXML)
ConsoleWrite("-The exported profile:" & @CRLF & $ProfileXML & @CRLF)

$Return = _Wlan_DeleteProfile(-1, -1, $Profile[0])
If @error Then ConsoleWrite("!Err[" & @error & "] Ext[" & @extended & "] - " & $Return)

_Wlan_EndSession(-1)

You should also be using _Wlan_CloseHandle() instead of calling _Wlan_EndSession in that context as EndSession will close the Dll handle causing any following functions to fail.

A more efficient way of doing things would be to call _Wlan_StartSession once at the start of your script and call _Wlan_EndSession at the end. (or better still from a registered exit function - if you plan to use the functions with "wait" in them!)

Cheers,

Matt

Edited by MattyD

Share this post


Link to post
Share on other sites

Hey man,

There seems to be a mistake on line 534 of the UDF. ($pGUID and $hClientHandle are back to front.) It should be...

$Return = _Wlan_SetProfileUserDataXML($SSID, $Return, $pGUID, $hClientHandle)

Thats what it was. I hate it when the obvious eludes me, I compared that line to MSDN and missed the error :graduated:

With that fixed, this following code works on win7...

#RequireAdmin
#include <wifi33a.au3>
Local $asProfile[4][6]
$asProfile[0][0] = "Test(PEAP-MSCHAP)"
$asProfile[0][3] = "WPA2"
$asProfile[0][4] = "AES"
$asProfile[0][5] = "802.1x Enabled"
$asProfile[1][0] = "PEAP"
$asProfile[1][1] = "Fast Reconnect"
$asProfile[1][2] = "No Quarantine Checks"
$asProfile[1][3] = "Don't Require Cryptobinding"
$asProfile[2][0] = "Validate Certificate"
$asProfile[2][1] = "Don't Prompt User"
$asProfile[3][0] = "MSCHAP"
$asProfile[3][1] = "Don't Use Win Logon"

Local $asUserData
$asUserData[0] = "PEAP-MSCHAP"
$asUserData[1] = "dev"
$asUserData[2] = "adm01"
$asUserData[3] = "Querty!23"

$sReturn = _Wlan_StartSession()
If @error Then _ReportError(@error, @extended, $sReturn, @ScriptLineNumber)

$sReturn = _Wlan_SetProfile($asProfile)
If @error Then _ReportError(@error, @extended, $sReturn, @ScriptLineNumber)

$sReturn = _Wlan_SetProfileUserData($asProfile[0][0], $asUserData)
If @error Then _ReportError(@error, @extended, $sReturn, @ScriptLineNumber)

Func _ReportError($iError, $iExtended, $sReturn, $iLine)
    MsgBox(0, "Error!", "Error @ln(" & $iLine & ") err[" & $iError & "] ext[" & $iExtended & "]" & @CRLF & $sReturn)
EndFunc
...almost :(

Local $asUserData

should read

Local $asUserData[4]

and it works perfectly!

I have one more problem - my environment has lots of non domain workstations that need wireless access at logon. In Win7, after the profile is created, this can be done by

> Wireless Profile Properties

> Security

> Advanced Settings

> Specify authentication mode: User Authentication

> Save Credentials

Windows will now establish wireless connectivity at the logon screen at startup, not just after logging off. The "Single Sign On" option doesn't work due to it being a non domain machine.

How do I programmatically save these credentials? I've played with "netsh wlan set properties" and they only allow setting the authentication mode.

netsh wlan set profileparameter name=uDev80211 authMode=userOnly

I also can't find anything at this page:

http://msdn.microsoft.com/en-us/library/ms706274%28v=VS.85%29.aspx

How does Windows do it?

Cheers

Share this post


Link to post
Share on other sites

Hey dottxt,

Local $asUserData

should read

Local $asUserData[4]

and it works perfectly!

Bad Matty! - Thanks man I'll correct the post.

At best guess it will be some functionality I left out of the OneX element in the original profile. (may aim at that point was just to achieve comprehensive XP support!)

Thake a look here (particularly under authMode and probably cacheUserData)

The GetProfileXML function and SetProfileXML method might work with a bit of fiddling around.

you will either have to go into the udf and add the WLAN_PROFILE_GET_PLAINTEXT_KEY flag to the dll call (i'll post a more detailed description on how to do this when I get some more time) or just edit the encryption key and keytype elements manually in the XML profile.

There is also a WlanSetProfileCustomUserData function as well which I havn't looked in to...

Sorry I couldn't be of more help. probably won't be able to have a good look at it til next week.

Good luck,

Matt

Share this post


Link to post
Share on other sites

Scratch that. Obviously you aren't using a PSK so that bit about the "GetPlainTxt" flag is totally irrelevant.

The profile happily creates when adding these two lines directly under the <OneX xmlns="http://www.microsoft.com/networking/OneX/v1"> line of the XML.

<cacheUserData>true</cacheUserData>
<authMode>user</authMode>

does this help? (I don't have a radius server to test...)

Share this post


Link to post
Share on other sites

I am trying to use this v3.3a of this lib to automate dot1x authentication testing by a client; I am not clear how to pass the username/password in this case; Please note for the simple case I am not using any certificate. if somebody has a script developed in this regard can they please share it;

thanks

Chandra

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...