Guest User

Untitled

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