netsh - View and Change Network Settings

Maintained on

netsh (Network Shell) is a command for viewing and changing Windows network settings from the command line. It handles Wi-Fi connection data, IP address and DNS settings, the firewall, and more.

While ipconfig mostly shows the current state, netsh can also change settings.

Basic Syntax of the netsh Command

netsh [context] [subcontext] <command> [options]

The depth of contexts varies by command (winsock reset has one level, interface ip show config has two).

netsh uses a “context” for each area you want to work with. Common ones are:

ContextTarget
wlanWireless LAN (Wi-Fi)
interfaceIP settings of network adapters
advfirewallMicrosoft Defender Firewall
winsockWinsock catalog

If you get lost, type part of a command followed by ? to list the commands available at that level.

netsh wlan ?

List Saved Wi-Fi Networks

netsh wlan show profiles
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netsh wlan show profiles
Profiles on interface Wi-Fi:
User profiles
-------------
All User Profile : home-wifi
All User Profile : cafe-free-wifi
C:\users\user>

The output text depends on the Windows display language.

Show a Saved Wi-Fi Password

Specify the profile name with name= and add key=clear.

netsh wlan show profile name="home-wifi" key=clear

The password appears as “Key Content” under “Security settings”.

Administrator rights may be required

Depending on the saved profile, “Key Content” may not appear unless you run as administrator. The password is displayed on screen, so make sure it does not show up in screenshots or screen sharing. Use this only to check passwords on your own device.

Show IP Address Settings

netsh interface ip show config

For each adapter, it shows the IP address, subnet mask, default gateway, and DNS servers.

To list adapter names:

netsh interface show interface

Set an IP Address and DNS

These examples assume the adapter is named Wi-Fi. Changing settings requires administrator rights.

Set
netsh interface ip set address name="Wi-Fi" static 192.168.1.50 255.255.255.0 192.168.1.1
Set
netsh interface ip set dnsservers name="Wi-Fi" static 8.8.8.8
Return
netsh interface ip set address name="Wi-Fi" dhcp
netsh interface ip set dnsservers name="Wi-Fi" dhcp
Wrong values can cut off your connection

An incorrect IP address or gateway can leave you unable to connect. Use the adapter name exactly as shown by netsh interface show interface. Note the original values with netsh interface ip show config first, and use the DHCP commands above to recover.

Reset Winsock

When your connection is unstable, one remedy is to reset the Winsock catalog to its default state.

netsh winsock reset

This requires administrator rights, and you must restart the PC afterward. It may also affect VPN and security software settings. If other causes are possible, first clear the DNS cache with ipconfig /flushdns or check connectivity with ping.

Create a Wi-Fi Diagnostic Report

netsh wlan show wlanreport

Administrator rights are required. This creates an HTML report summarizing the past few days of Wi-Fi connection history, errors, and causes of disconnections. The default output path is C:\ProgramData\Microsoft\Windows\WlanReport\wlan-report-latest.html.

Use It in a Batch File

wifi-password.cmd
@echo off

set /p WIFI_NAME=Enter the Wi-Fi profile name:
netsh wlan show profile name="%WIFI_NAME%" key=clear | findstr /i /c:"Key Content"
pause

findstr narrows the output to the line containing the key. The label is localized, so adjust the search word to match your display language.

Summary

GoalCommand
List saved Wi-Fi networksnetsh wlan show profiles
Show a Wi-Fi passwordnetsh wlan show profile name="Name" key=clear
Show IP settingsnetsh interface ip show config
Return to DHCPnetsh interface ip set address name="Name" dhcp
Reset Winsocknetsh winsock reset
Wi-Fi diagnostic reportnetsh wlan show wlanreport

Practice Questions

Practice Problem

Which option is needed to display a saved Wi-Fi password?

Choose one answer.

  1. name=password
  2. key=clear
  3. show=all

Practice Problem

What do you need to do after running netsh winsock reset?

Choose one answer.

  1. Unplug and replug the network cable
  2. Restart the PC
  3. Nothing
#Command Prompt #Command Line #Commands #Network #Wi-Fi