The following is the tool program for LAN chat that I wrote. Although it doesn't have much value, it uses most batch commands, including some important commands and more difficult ones. I'm posting it, hoping that new friends learning batch processing will like it. I believe it's very valuable for everyone to learn and understand relevant batch commands. This is the modified version
@echo off
title LAN Chat Tool
color 1f
MODE con: COLS=54 lines=34
:choose
cls
echo\
echo ┏━━━━━━━━━━━━━━━━━━━┓
echo ┃ ┃
echo ┃ LAN Chat Tool ┃
echo ┃ copyright by jellord ┃
echo ┗━━━━━━━━━━━━━━━━━━━┛
echo\
echo.
echo ===============================================
echo.
echo To use this software, you must ensure that your computer has started the Windows Messenger service. Otherwise, please follow these methods to enable it:
echo.
echo 1. Enter net start messenger in the Run box;
echo 2. Enter the Control Panel, then enter Administrative Tools, and then enter the Service program, find the messenger service and start it.
echo.
echo ===============================================
echo.
set /p choose=Please choose (1/Quit program and start messenger service; 2/Continue):
if /i "%choose%"=="1" goto
if /i "%choose%"=="2" goto 2
echo.
echo. ---------Incorrect input, please try again!----------&&echo.&&pause&&goto choose
:2
if exist ip.txt del /q ip.txt
cls
echo\
echo ┏━━━━━━━━━━━━━━━━━━━┓
echo ┃ ┃
echo ┃ LAN Chat Tool ┃
echo ┃ copyright by jellord ┃
echo ┗━━━━━━━━━━━━━━━━━━━┛
echo\
echo Scanning online users in the LAN, please wait...
echo.
echo /////////////////////////////////////////////////////
echo IP Computer Name
setlocal enabledelayedexpansion
net view|find "\\">lan.txt
for /f "usebackq" %%j in ('lan.txt') do (
if "%%~zj"=="0" (
echo Sorry, there are currently no active users online!&&echo Sorry, there are currently no active users online!
>ip.txt
) else (
for /f "tokens=1" %%i in (lan.txt) do (
set co=%%i
set co=!co:\\=!
ping -w 1 -n 1 !co!|find /I "!co!">ping.txt
for /f "tokens=2,3 delims= " %%a in (ping.txt) do if not "%%b"=="could" echo %%b
%%a
for /f "tokens=2,3 delims= " %%a in (ping.txt) do if not "%%b"=="could" echo %%b
%%a >>ip.txt
)
)
)
if exist lan.txt del /q lan.txt&if exist ping.txt del /q ping.txt
echo.
echo /////////////////////////////////////////////////////
echo The above shows the online users in the LAN currently
echo.
rem ============================================================================================
rem The part between the above slashes can also be implemented with the following code to achieve the same function, and it will not generate temporary text files at the same time.
rem setlocal enabledelayedexpansion
rem net view|find "\\">nul||echo Sorry, there are currently no active users online!||echo Sorry
, there are currently no active users online!>ip.txt
rem for /f "tokens=1" %%i in ('net view ^| find "\\"') do (
rem set co=%%i
rem set co=!co:\\=!
rem for /f "tokens=2,3 delims= " %%a in ('ping -w 1 -n 1 !co! ^| find /I "!co!"') do if not
%%b"=="could" echo %%b %%a
rem for /f "tokens=2,3 delims= " %%a in ('ping -w 1 -n 1 !co! ^| find /I "!co!"') do if not
%%b"=="could" echo %%b %%a>>ip.txt
rem )
rem pause
rem ============================================================================================
:user
set /p u=Please choose the computer name or IP of the other party (note the case):
echo.
type ip.txt|find "%u%">nul||echo. -----------Input is not in the scanning result, please try again!------------&&goto p
type ip.txt|find "%u%">nul&&goto main
:p
echo.
set /p l=Please choose (1/Insist on sending; press Enter to return):
if "%l%"=="" echo.&goto user
if "%l%"=="1" goto main
echo.
goto user
:main
cls
echo.
echo ┏━━━━━━━━━━━━━━━━━━━┓
echo ┃ 1: Send message 3: Re-select sending object ┃
echo ┃ 2: View chat history 4: Re-scan LAN ┃
echo ┃ 0: Quit program ┃
echo ┗━━━━━━━━━━━━━━━━━━━┛
echo.
echo You are currently chatting with %u%...
echo.
set c=
set /p c=Please make your choice:
if /i "%c%"=="4" del /q ip.txt&cls&goto 2
if /i "%c%"=="3" cls&&echo.&&echo The last scanned online users are shown below
:&&echo.-----------------------------------------------------&&type ip.txt&&echo.&&goto user
if /i "%c%"=="0" if exist ip.txt del /q ip.txt&goto
if /i "%c%"=="2" goto 3
if /i "%c%"=="1" goto work
echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
echo Your choice is incorrect!
echo Please re-select
echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
pause
goto main
:work
cls
echo.-----------------------------------------------------
echo.
echo You are currently chatting with %u%...
echo.
echo You can press Enter to return to the previous menu during the chat
echo.
echo.-----------------------------------------------------
set m=
set /p m=Please enter the message you want to send:
echo.
echo.
if "%m%"=="" (
goto main
) else (
echo You said to %u% at %date% %time%: %m%>>messege.txt
echo.Sending message, please wait...
net send %u% %m%
pause
goto work
)
:3
echo.-----------------------------------------------------
set /p t=Please choose (1/Display in current window; 2/Display in new window):
if "%t%"=="1" goto t
if "%t%"=="2" goto s
echo -----------------------------------------------------
echo Incorrect choice!
goto 3
:t
cls
echo.-----------------------------------------------------
type messege.txt|more&pause
goto main
:s
start messege.txt
goto main
[ Last edited by jellord on 2007-4-5 at 08:50 PM ]
@echo off
title LAN Chat Tool
color 1f
MODE con: COLS=54 lines=34
:choose
cls
echo\
echo ┏━━━━━━━━━━━━━━━━━━━┓
echo ┃ ┃
echo ┃ LAN Chat Tool ┃
echo ┃ copyright by jellord ┃
echo ┗━━━━━━━━━━━━━━━━━━━┛
echo\
echo.
echo ===============================================
echo.
echo To use this software, you must ensure that your computer has started the Windows Messenger service. Otherwise, please follow these methods to enable it:
echo.
echo 1. Enter net start messenger in the Run box;
echo 2. Enter the Control Panel, then enter Administrative Tools, and then enter the Service program, find the messenger service and start it.
echo.
echo ===============================================
echo.
set /p choose=Please choose (1/Quit program and start messenger service; 2/Continue):
if /i "%choose%"=="1" goto
if /i "%choose%"=="2" goto 2
echo.
echo. ---------Incorrect input, please try again!----------&&echo.&&pause&&goto choose
:2
if exist ip.txt del /q ip.txt
cls
echo\
echo ┏━━━━━━━━━━━━━━━━━━━┓
echo ┃ ┃
echo ┃ LAN Chat Tool ┃
echo ┃ copyright by jellord ┃
echo ┗━━━━━━━━━━━━━━━━━━━┛
echo\
echo Scanning online users in the LAN, please wait...
echo.
echo /////////////////////////////////////////////////////
echo IP Computer Name
setlocal enabledelayedexpansion
net view|find "\\">lan.txt
for /f "usebackq" %%j in ('lan.txt') do (
if "%%~zj"=="0" (
echo Sorry, there are currently no active users online!&&echo Sorry, there are currently no active users online!
>ip.txt
) else (
for /f "tokens=1" %%i in (lan.txt) do (
set co=%%i
set co=!co:\\=!
ping -w 1 -n 1 !co!|find /I "!co!">ping.txt
for /f "tokens=2,3 delims= " %%a in (ping.txt) do if not "%%b"=="could" echo %%b
%%a
for /f "tokens=2,3 delims= " %%a in (ping.txt) do if not "%%b"=="could" echo %%b
%%a >>ip.txt
)
)
)
if exist lan.txt del /q lan.txt&if exist ping.txt del /q ping.txt
echo.
echo /////////////////////////////////////////////////////
echo The above shows the online users in the LAN currently
echo.
rem ============================================================================================
rem The part between the above slashes can also be implemented with the following code to achieve the same function, and it will not generate temporary text files at the same time.
rem setlocal enabledelayedexpansion
rem net view|find "\\">nul||echo Sorry, there are currently no active users online!||echo Sorry
, there are currently no active users online!>ip.txt
rem for /f "tokens=1" %%i in ('net view ^| find "\\"') do (
rem set co=%%i
rem set co=!co:\\=!
rem for /f "tokens=2,3 delims= " %%a in ('ping -w 1 -n 1 !co! ^| find /I "!co!"') do if not
%%b"=="could" echo %%b %%a
rem for /f "tokens=2,3 delims= " %%a in ('ping -w 1 -n 1 !co! ^| find /I "!co!"') do if not
%%b"=="could" echo %%b %%a>>ip.txt
rem )
rem pause
rem ============================================================================================
:user
set /p u=Please choose the computer name or IP of the other party (note the case):
echo.
type ip.txt|find "%u%">nul||echo. -----------Input is not in the scanning result, please try again!------------&&goto p
type ip.txt|find "%u%">nul&&goto main
:p
echo.
set /p l=Please choose (1/Insist on sending; press Enter to return):
if "%l%"=="" echo.&goto user
if "%l%"=="1" goto main
echo.
goto user
:main
cls
echo.
echo ┏━━━━━━━━━━━━━━━━━━━┓
echo ┃ 1: Send message 3: Re-select sending object ┃
echo ┃ 2: View chat history 4: Re-scan LAN ┃
echo ┃ 0: Quit program ┃
echo ┗━━━━━━━━━━━━━━━━━━━┛
echo.
echo You are currently chatting with %u%...
echo.
set c=
set /p c=Please make your choice:
if /i "%c%"=="4" del /q ip.txt&cls&goto 2
if /i "%c%"=="3" cls&&echo.&&echo The last scanned online users are shown below
:&&echo.-----------------------------------------------------&&type ip.txt&&echo.&&goto user
if /i "%c%"=="0" if exist ip.txt del /q ip.txt&goto
if /i "%c%"=="2" goto 3
if /i "%c%"=="1" goto work
echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
echo Your choice is incorrect!
echo Please re-select
echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
pause
goto main
:work
cls
echo.-----------------------------------------------------
echo.
echo You are currently chatting with %u%...
echo.
echo You can press Enter to return to the previous menu during the chat
echo.
echo.-----------------------------------------------------
set m=
set /p m=Please enter the message you want to send:
echo.
echo.
if "%m%"=="" (
goto main
) else (
echo You said to %u% at %date% %time%: %m%>>messege.txt
echo.Sending message, please wait...
net send %u% %m%
pause
goto work
)
:3
echo.-----------------------------------------------------
set /p t=Please choose (1/Display in current window; 2/Display in new window):
if "%t%"=="1" goto t
if "%t%"=="2" goto s
echo -----------------------------------------------------
echo Incorrect choice!
goto 3
:t
cls
echo.-----------------------------------------------------
type messege.txt|more&pause
goto main
:s
start messege.txt
goto main
[ Last edited by jellord on 2007-4-5 at 08:50 PM ]
Recent Ratings for This Post
( 1 in total)
Click for details
| Rater | Score | Time |
|---|---|---|
| htysm | +2 | 2007-04-16 05:31 |
