@echo off
setlocal enabledelayedexpansion
color 1a
:again
cls
set num=
set endnum=
set message=
echo.
echo.
echo telnet會話管理
echo 1.開啟telnet服務
echo 2.列出所有的telnet會話
echo 3.終止選定的telnet會話
echo 4.向指定telnet會話發信息
echo 5.向所有telnet會話發信息
echo 6.結束telnet服務
echo 7.退出程序
echo.
echo.
set /p num=請選擇要執行的操作:
if "!num!"=="1" (
cls
echo.
echo.
sc config tlntsvr start= demand >nul
sc start tlntsvr >nul
net stop sharedaccess >nul
echo telnet服務已成功開啟,請返回繼續操作...
pause >nul
goto again
)
if "!num!"=="2" (
cls
tlntadmn -s
echo 請返回重新選擇...
pause >nul
goto again
)
if "!num!"=="3" (
cls
tlntadmn -s
tlntadmn -s | find "沒有"
if not errorlevel 1 (
echo 沒有建立telnet會話,請返回重新輸入...
pause >nul
goto again
)
:inptid
echo.
set /p endnum=請輸入要終止的telnet會話ID:
if "!endnum!"=="" (
echo telnet會話ID輸入無效,返回重新輸入...
goto inptid
)
tlntadmn -k !endnum!
echo.
echo 已成功終止制定的會話,請返回重新選擇...
pause >nul
goto again
)
if "!num!"=="4" (
cls
tlntadmn -s
tlntadmn -s | find "沒有"
if not errorlevel 1 (
echo 沒有建立telnet會話,請返回重新輸入...
pause >nul
goto again
)
:inptid2
echo.
set /p endnum=請輸入要發送信息的telnet會話ID:
if "!endnum!"=="" (
echo telnet會話ID輸入無效,返回重新輸入...
goto inptid2
)
echo.
set /p message=請輸入要發送信息:
tlntadmn -m !endnum! !message!
echo 信息已經發送成功,請返回重新選擇...
pause >nul
goto again
)
if "!num!"=="5" (
cls
tlntadmn -s
tlntadmn -s | find "沒有"
if not errorlevel 1 (
echo 沒有建立telnet會話,請返回重新輸入...
pause >nul
goto again
)
echo.
set /p message=請輸入要發送信息:
tlntadmn -m all !message!
echo 信息發送成功,請返回重新選擇...
pause >nul
goto again
)
if "!num!"=="6" (
cls
echo.
echo.
sc config tlntsvr start= disabled >nul
sc stop tlntsvr >nul
net start sharedaccess >nul
echo telnet服務已成功終止,請返回繼續操作...
pause >nul
goto again
)
if "!num!"=="7" (
goto exit
)
:exit
set num=
set endnum=
set message=
|