forked from Abhisheksinha1506/Collection-of-Useful-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 2
/
A script to view the wireless SSIDs and security keys stored on this computer.bat
88 lines (78 loc) · 2.41 KB
/
A script to view the wireless SSIDs and security keys stored on this computer.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@echo off
:START
color 1F
cls
title View wireless SSID list
::Display list of SSIDs stored in this computer and prompt user to choose one
Netsh wlan show profiles
Echo If you wish to view the security key for one of the above SSIDs,
Set /p SSID=enter its name here:
echo.
::Detect whether the user's chosen SSID is in the list
Netsh wlan show profiles name= %SSID% > NUL
If errorlevel 1 (
::warn user that SSID is not in the list, then start over
color 6f
echo.
echo Sorry, that SSID is not found.
pause
goto start
)
:VIEWKEY
::The below spacing is deliberately wide for readability of results when a security key is displayed
echo SSID : %SSID%
::Display key content if available
netsh wlan show profile name="%SSID%" key=clear | find "Key Content"
If errorlevel 1 (
::Turn yellow and warn if a key is not found for this SSID
color 6f
echo The security key is not found for this SSID.
echo It is possible that this SSID is open and does not
echo require a key, or one may not have been saved.
echo.
) ELSE (
::Turn green if a key was found for this SSID
color 2f)
echo.
::Give the user a chance to view another key
choice /c EVR /m "Would you like to (E)xit, (V)iew another key, or (R)emove this profile?"
If errorlevel 3 goto RemoveWarning
If errorlevel 2 goto start
If errorlevel 1 goto exit
:EXIT
exit /b
:RemoveWarning
::warn user that they are about to delete the profile
color 4f
cls
echo ***********
echo * WARNING *
echo ***********
echo.
echo This computer will forget the profile and security key
echo for the wireless network named "%SSID%".
echo.
choice /c YN /m " Are you sure this is what you want to do?"
If errorlevel 2 goto start
If errorlevel 1 goto keyremoval
:keyremoval
::Attempt to remove the profile
cls
netsh wlan delete profile name="%SSID%" | find "is deleted"
If errorlevel 1 (
::Turn red and warn if a the profile could not be removed.
color 4f
echo.
echo That profile was not found or could not be deleted.
echo Please check the name and try again.
echo If the name contains any special characters, it may need
echo to be deleted manually instead.
pause
goto start
) ELSE (
::Turn green if the profile was removed successfully
color 2f
echo.
echo Press any key to exit.
pause >nul
)