Find stored WiFi SSID + PASSWORD

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 1115
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Find stored WiFi SSID + PASSWORD

Post by Grovkillen » Wed Apr 01, 2020 7:35 am

Code: Select all

  Let>RP_WAIT=1
  //Let>RP_WINDOWMODE=1

  MidStr>%SCRIPT_DIR%,0,1,VOLUME_LETTER
  IfFileExists>%SCRIPT_DIR%\wlan.txt
    DeleteFile>%SCRIPT_DIR%\wlan.txt
  Endif>
  Let>COMMAND_LINE_STRING=cmd /c %VOLUME_LETTER%: & cd "%SCRIPT_DIR%" & netsh wlan show profiles > "wlan.txt"
  RunProgram>COMMAND_LINE_STRING
  ReadFile>%SCRIPT_DIR%\wlan.txt,TEMP_WLAN_SSID
  Let>REGEX_PATTERN=(?<=All User Profile     : ).+?(?=\r\n)
  RegEx>REGEX_PATTERN,TEMP_WLAN_SSID,0,SSID,SSID_n,0,,
  IfFileExists>%SCRIPT_DIR%\wlan.txt
    DeleteFile>%SCRIPT_DIR%\wlan.txt
  Endif>
  IfFileExists>%SCRIPT_DIR%\ssid_key.txt
    DeleteFile>%SCRIPT_DIR%\ssid_key.txt
  Endif>
  Let>REGEX_PATTERN=(?<=Key Content            : ).+?(?=\r\n)
  Let>LIST=SSID:PASSWORD%CRLF%
  Let>k=0
  Repeat>k
    Let>k=k+1
    Let>TEMP_SSID=SSID_%k%
    Let>COMMAND_LINE_STRING=cmd /c %VOLUME_LETTER%: & cd "%SCRIPT_DIR%" & netsh wlan show profile name="%TEMP_SSID%" key=clear > "ssid_key.txt"
    RunProgram>COMMAND_LINE_STRING
    ReadFile>%SCRIPT_DIR%\ssid_key.txt,TEMP_WLAN_SSID
    RegEx>REGEX_PATTERN,TEMP_WLAN_SSID,0,TEMP_KEY,TEMP_MATCHES,0,,
    IfNot>TEMP_MATCHES=0
      Let>SSID_KEY_%k%=TEMP_KEY_1
    Else>
      Let>SSID_KEY_%k%=>>>NO PASSWORD FOUND<<<
    Endif>
    ConCat>LIST,SSID_%k%
    ConCat>LIST,:
    ConCat>LIST,SSID_KEY_%k%
    ConCat>LIST,%CRLF%
    IfFileExists>%SCRIPT_DIR%\ssid_key.txt
      DeleteFile>%SCRIPT_DIR%\ssid_key.txt
    Endif>
    DelArray>TEMP_KEY
  Until>k=SSID_n

PutClipBoard>LIST
Let>RP_WAIT=0
Run>Notepad
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1115
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Find stored WiFi SSID + PASSWORD

Post by Grovkillen » Tue Sep 10, 2024 8:46 am

Thanks to self, this came in handy today.
Let>ME=%Script%

Running: 15.0.27
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts