Every time I search for this I get pages long articles with 99% of babbling when the solution is 2 lines. I think it can be used for Windows 7, 8, 10, 11,…
NOTE: you must have connected and stored password for that wifi in the past. This trick is to see password that is already stored on your computer (in case you forgot it), NOT to find out password on router for any wifi.
So here is how to do it:
Open CMD (some say in administrator mode but for me it worked OK without it too).
Type (can be small letters) NETSH WLAN SHOW PROFILE
You will get a list of all Wi-fi networks. Let say the name of network you want is MYWIFINET.
Type NETSH WLAN SHOW PROFILE MYWIFINET KEY=CLEAR
Scroll down to Security Settings and find Key Content (I hid my password with red color).
Next to it is the wifi password you are looking for.