Information Security 7 min read

How to Retrieve Saved WiFi Passwords on Windows Using CMD and Python

This guide shows how to list and export all saved WiFi profiles on a Windows PC via the command prompt and a Python script, explains the use of the subprocess module for executing system commands, and includes notes on UTF‑8 handling and related code examples.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
How to Retrieve Saved WiFi Passwords on Windows Using CMD and Python

The article explains how to find all saved WiFi passwords on a Windows computer using both the command prompt (CMD) and a Python script.

First, open CMD with administrator rights (e.g., press Windows + R , type cmd , and run as administrator). Run netsh wlan show profile to list all WiFi configuration profiles, then execute netsh wlan export profile folder=c:\ key=clear to export each profile together with its password to the C:\ directory.

For a faster solution, the article provides a Python script that uses the subprocess module. It changes the console code page to UTF‑8 with subprocess.run('chcp 65001', shell=True) , retrieves the list of profiles via subprocess.check_output(["netsh", "wlan", "show", "profiles"], shell=True, encoding='utf-8') , and iterates over each profile name. For each profile it runs netsh wlan show profile <profile> key=clear , extracts the line containing "Key Content", and prints the SSID and password, handling possible IndexError when a password is not stored.

The guide also details the subprocess.check_output function: it runs external commands, returns the output as bytes, can raise subprocess.CalledProcessError on non‑zero exit codes, and supports parameters such as shell=True , encoding='utf-8' , text=True , and timeout . Example snippets demonstrate capturing output, decoding it, and handling errors.

Additional notes discuss common UTF‑8 decoding errors when the command output contains non‑UTF‑8 characters and recommend using chcp 65001 to set the console code page before running the commands.

At the end, the article includes promotional material offering a free Python public course and additional learning resources via QR code links.

PythonWiFiinformation securitywindowsCMDsubprocess
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.