I’ve done the same (well, similar) using an AutoHotkey wrapper. Have a look at Help for Win10 1607’s confusing Wi-Fi settings – Page 2 | Windows Secrets Lounge. Since then I’ve improved it so it’s now at v3.
Code:
; Get stored WiFi profiles and passwords v3 ; See Thanks to ‘garry’ in the AHK forum for suggestimg ‘FileRead’ instead of ‘FileReadLine’ #SingleInstance force ; Force only one instance at a time#SingleInstance force ; Prompt to ‘Run as Admin’, i.e. show UAC dialog If Not A_IsAdmin { Run *RunAs “%A_ScriptFullPath%” ; Requires v1.0.92.01+ ExitApp } ; ***** Housekeeping ***** SetWorkingDir, %A_ScriptDir% ; Set script to use the folder it’s run from FilesDir=%A_ScriptDir%\WifiXMLS ; Set folder for XML files IfNotExist, %FilesDir% ; Check whether folder exists FileCreateDir, %FilesDir% ; … and create the folder if it doesn’t exist FileDelete, %FilesDir%\*.xml ; Make sure there are no existing XML files IfExist Results.txt ; Make sure there is no existing Results.txt file FileDelete, Results.txt FileAppend, Stored WiFi passwords are as follows:`n`n, Results.txt ; Create first line of new Results.txt file ; ***** Export profiles ***** RunWait, %comspec% /c “netsh wlan export profile folder=%FilesDir% key=clear”, hide ; Exports all WiFi profiles ; ***** Loop through/parse generated files ***** FileList = ; Initialize to be blank Loop, %FilesDir%\*.xml ; Loop through the XML files FileList = %FileList%%A_LoopFileName%`n ; Generate a filelist Sort, FileList, ; Sort the filelist alphabetically Loop, %FilesDir%\*.xml ; Loop through each file { string:= ; Store contents of file in variable xmlfile:=A_LoopFileFullPath ; With each file, with its path FileRead, string, %xmlfile% ; … read each file into memory Loop, parse, string, `n, `r ; Parse each line using LineFeed (`n) and Carriage Return (`r) { lines:= A_LoopField ` ; Store lines in variable if lines contains ; Check lines for 1st criteria { L%a_index%:=RegExReplace( lines, ) ssid:= % L%a_index% ; Store search result in variable } if lines contains ; Check lines for 2nd criteria { L%a_index%:=RegExReplace( lines, ) auth:= % L%a_index% ; Store search result in variable } if lines contains ; Check lines for 3rd criteria { L%a_index%:=RegExReplace( lines, ) crypt:= % L%a_index% ; Store search result in variable } if lines contains ; Check lines for 4th criteria { L%a_index%:=RegExReplace( lines, ) password:= % L%a_index% ; Store search result in variable ssid=%ssid% ; Keep just the data between and auth=%auth% ; Keep just the data between and crypt=%crypt% ; Keep just the data between and password=%password% ; Keep just the data between and resultbasic .= “XML profile:”A_Tab . xmlfile . “`nSSID:”A_Tab A_Tab . ssid “`nPassword:”A_Tab . password . “`n-`n” resultverbose .= “XML profile:”A_Tab . xmlfile . “`nSSID:”A_Tab A_Tab . ssid “`nPassword:”A_Tab . password . “`nAuthentication:”A_Tab . auth . “`nEncryption:”A_Tab . crypt . “`n-`n” ; Break ; Used for testing } } } ; ***** Display a message box, with custom button names, offering a choice of info ***** SetTimer, ChangeButtonNames, 50 MsgBox, 36, WiFi Profile Info, What info would you like?`n`nBasic, i.e. show just passwords`nVerbose, i.e. show passwords and security`n`nChoose a button… IfMsgBox, YES { FileAppend, %resultbasic%, results.txt ; Write the basic results to the text file FileAppend, `nNote: Only wireless access points with passwords are listed above.`n, Results.txt ; Create last line of new Results.txt file Run, results.txt ; Open the file in whatever app is registered to display text files ExitApp ; Exit the script } else { FileAppend, %resultverbose%, results.txt ; Write the verbose results to the text file FileAppend, `nNote: Only wireless access points with passwords are listed above.`n, Results.txt ; Create last line of new Results.txt file Run, results.txt ; Open the file in whatever app is registered to display text files ExitApp ; Exit the script } return ChangeButtonNames: IfWinNotExist, WiFi Profile Info return ; Keep waiting. SetTimer, ChangeButtonNames, off WinActivate ControlSetText, Button1, &Basic ControlSetText, Button2, &Verbose return Esc::ExitApp ; Used to cancel the MsgBox, if needed
Hope this helps…