How to find out your Wi-Fi password using the command line

It's quite common to need to connect to a wireless network with a new device but have forgotten or lost the password. Fortunately, the operating system Windows Stores data about previously used connections in a dedicated security profile. This allows you to quickly restore internet access without having to reset your router or interfere with your ISP.

Using the console is the most reliable method for experienced users and system administrators. Unlike the graphical interface, which requires multiple clicks, the command line provides direct access network configurationsThis method is universal and works on most OS versions, from Windows 7 to the latest builds of Windows 11.

In this article, we'll detail the steps to extract a saved security key. We'll cover basic commands, methods for exporting data to a text file, and troubleshooting common errors. You'll learn how to manage network profiles professionally and securely.

Preparing the command line for work

Before making any changes to system parameters, you must obtain the appropriate access rights. Standard user mode does not allow viewing sensitive data, such as encryption keysTherefore, the first step should always be to launch the terminal as administrator. This is critical, otherwise the system will return an access error.

To open the quick access menu, press the key combination Win + XIn the list that appears, select "Windows PowerShell (Administrator)" or "Command Prompt (Administrator)." Depending on your operating system version, the utility name may differ, but the principle remains the same: elevated privileges are required.

⚠️ Warning: Running the console without administrator rights will result in you receiving an access denied message when entering commands, even if the syntax is entered correctly.

An alternative method is to search for "cmd," right-click the result, and select "Run as administrator." Once a black terminal window opens, you're ready to enter control codes. The command line interface can be intimidating for beginners, but it provides direct control over network stack operating system.

Viewing a list of saved profiles

Before requesting a specific password, you must ensure that the desired network profile is actually stored in the computer's memory. Windows Keeps a log of all connections ever accessed from a given device. This is convenient for managing multiple access points in an office or public space.

To get a list of all known networks, enter the following command:

netsh wlan show profiles

After pressing the key Enter The system will display a list under the heading "Profiles by User." Please note the exact name of your network, as you will need it in the next step. Sometimes names may contain spaces or special characters, which you will need to account for when entering.

If you plan to work with a large number of profiles, it's helpful to know that you can sort them. However, the default command produces a general list. The output may also show the number of profiles and the storage type (usually "User").

📊 How often do you forget your Wi-Fi password?
Once a week
Once a month
Only when purchasing a new router
I never forget

Obtaining the password for a specific network

Now that the profile name is known, you can request to display its properties, including security keyTo do this, use a modified version of the previous command, specifying the network name and the key parameter. The syntax requires precision: the network name must be enclosed in quotation marks if it contains spaces.

Enter the command in the format:

netsh wlan show profile name="Network_Name" key=clear

Replace Network_Name to the real name of your Wi-Fi. Parameter key=clear is key specifically for our task - it tells the system to display the contents of the security field in clear text, rather than hiding it with asterisks.

In the window that opens, find the "Security settings" section. We're interested in the "Key Content" line. The value to the right of the colon is your password. Copy it carefully, paying attention to the capitalization of the letters.

⚠️ Note: Be careful when entering the network name. If the network is called "Home WiFi," entering "home wifi" may result in the error "The wireless network name is not found."

This method works for networks with WPA2-Personal and WPA3 security types, which are the de facto standard for home use. For corporate networks with 802.1x authentication, the procedure may differ, as they use certificates or domain credentials.

☑️ Check before entering a command

Completed: 0 / 4

Comparison of Methods: GUI vs. CMD

Users often wonder which method is more efficient: using a graphical interface or entering text commands. Each method has its advantages depending on the situation. The graphical interface is more intuitive, but requires more mouse input.

Below is a table comparing the main characteristics of both approaches:

Characteristic Graphical user interface (GUI) Command Prompt (CMD)
Access speed Slower (many clicks) Instantly (one line)
Requirements Working graphical shell Terminal access only
Convenience of copying Difficult (hidden text) Easy (text open)
Automation Impossible Possibly through scripts

Usage cmd This is especially relevant during remote administration or when the system's graphical interface is unstable. Furthermore, text output is easier to save to a log file for later analysis.

On the other hand, for a one-time password view on a personal laptop, many find it easier to go through the "Network and Sharing Center" menu. However, knowledge of console commands is a sign of high digital literacy and is often required when passing exams or working in the IT field.

Export data to a text file

If you need to save network information or share it with a colleague, it's most convenient to redirect the command output to a text file. This eliminates the need to take screenshots or manually rewrite the data. The operating system makes this easy to implement using the redirection operator.

Use the symbol construction > at the end of the command:

netsh wlan show profile name="Network_Name" key=clear > C:\wifi_pass.txt

This command will create a file wifi_pass.txt on the C drive, where all output, including the cleared password, will be written. You can open this file with any text editor, such as Notepad. This is especially useful for backing up settings before reinstalling the system.

⚠️ Warning: The password file will contain sensitive information in clear text. Do not share this file with third parties and delete it immediately after use.

The path to the file can be changed to any convenient one, for example, to the desktop: > C:\Users\Name\Desktop\pass.txtThe main thing is that your account has write access to the specified directory.

What to do if the file is not created?

If the file doesn't appear, check that the terminal is running as administrator. Also, make sure the folder path is correct and doesn't contain any syntax errors. Sometimes, antivirus software can block file creation in system folders.

Deleting and managing network profiles

The command line allows you to not only view but also delete old or unnecessary profiles. Over time, many of these can accumulate, which can lead to connection conflicts or slow down the network search process. Clearing the profile list is a good system maintenance practice.

To delete a specific profile, use the command:

netsh wlan delete profile name="Network_Name"

The system will ask you to confirm the action. Once deleted, the profile will disappear from the list, and you'll need to re-enter the password to reconnect. This is useful if you've changed your router but your computer is trying to connect to the old network with the same name (SSID) but different security settings.

You can also reset all wireless settings at once, although this is a drastic measure. It may be necessary for in-depth diagnostics of network adapter issues. Keep in mind that deleting a profile does not delete the adapter drivers; it only erases saved connection configurations.

Possible errors and their solutions

During operation, situations may arise where a command fails to execute or produces unexpected results. This is most often due to typos in the network name or insufficient access rights. Attention to detail is the most important tool for a system administrator.

Let's look at typical problems:

  • 😟 Error "The wireless network name is not found": Check the exact spelling of the network name in the profile list. It must match character by character, including spaces and case.
  • 😟 Missing "Key Content" parameterThis means the current user does not have read permissions for the key. Make sure the console is running as administrator.
  • 😟 Syntax error: Make sure you put quotes around the network name if it contains spaces. Commands are formatting sensitive.

If problems persist, you can try updating your network adapter drivers or restarting the WLAN AutoConfig service. To do this, enter services.msc In the Run menu, find the service and select Restart.

Is it possible to find out the password for a Wi-Fi network I've never connected to?

No, the command prompt only displays profiles already saved on the computer. It's impossible to legally find out someone else's network password without first connecting and having saved data using CMD.

Does this method work on Windows 7 and 8?

Yes, team netsh wlan is supported in all modern versions of Windows, starting with Vista. The syntax remains virtually identical, but the output interface may differ slightly depending on the system's localization.

Is it safe to store passwords in text files?

Storing passwords in clear text (key=clear) creates the risk of data leakage if an intruder or virus uses your computer. It is recommended to use this method only temporarily to restore access and immediately change the password in the router settings to a new one.