Skip to content

Instantly share code, notes, and snippets.

@corlaez
Created December 27, 2019 00:17
Show Gist options
  • Select an option

  • Save corlaez/f23fc834a9cf20ded5b8cb10f3bdd897 to your computer and use it in GitHub Desktop.

Select an option

Save corlaez/f23fc834a9cf20ded5b8cb10f3bdd897 to your computer and use it in GitHub Desktop.
Batch file to check stored passwords.
@echo OFF
setlocal EnableDelayedExpansion
:start
:: Initialize password and substring
SET password=NONE
SET "substring=Key Content"
:: Print profiles
NETSH WLAN SHOW PROFILE
:: Ask for a profile name
SET /P profile= Please write one of the Profile names to see the password:
:: Write profile info to temp file
>output.tmp NETSH WLAN SHOW PROFILE "!profile!" KEY=CLEAR
:: Set password with the password if found
for /F "tokens=*" %%a in (output.tmp) do (
set string=%%a
if not "!string:%substring%=!"=="!string!" (
set password=!string!
)
)
:: If no password, reset.
IF "!password!"=="NONE" (
GOTO :reset
)
:: Print password
echo !password!
PAUSE
:reset
cls
GOTO :start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment