bat批处理示例(三)-查询历史wifi密码与探测存活主机

参考链接:https://blog.csdn.net/datanese/article/details/53227292

1.查询历史wifi密码:

wifi查询.bat:

@echo off
:main
echo WIFI History List:
netsh wlan show profiles

set /p wifi_name=please input the wifi_name you want:
netsh wlan show profile name="%wifi_name%" key=clear | findstr 关键内容 > E:\pwd.txt

for /f  "tokens=2  delims=:"  %%i  in  (E:\pwd.txt) do (
set aa=%%i
)
echo Password:%aa%

echo.
echo Do you want to search again?Y/N

set /p input=please input:
if %input%==Y goto main
if %input%==N goto exit

:exit
exit

2.从文本中读取ip探测存活主机:

(1)ip.txt:

192.168.75.1
192.168.75.2
192.168.75.3

(2)ping.bat:

@echo off
for /f %%i in (C:\Users\Jerry\Desktop\ip.txt) do (
	ping  %%i  /n 2  >nul && echo %%i is alive
)
pause

注意一个坑:ping  %%i  /n 2  >nul && echo %%i is alive中&&不可换成&,否则ping不通也打印is alive

你可能感兴趣的:(BAT)