China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-21 11:05
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Batch scripts for LAN chatting, which can learn most batch processing commands. View 4,148 Replies 33
Original Poster Posted 2007-04-03 12:10 ·  中国 福建 福州 电信
初级用户
Credits 92
Posts 26
Joined 2007-03-10 07:44
19-year member
UID 81291
Gender Male
Status Offline
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 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
htysm +2 2007-04-16 05:31
Floor 2 Posted 2007-04-03 12:45 ·  中国 广东 广州 天河区 电信
初级用户
Credits 55
Posts 23
Joined 2006-12-22 04:16
19-year member
UID 74239
Gender Male
From 广东
Status Offline
It's really powerful, but is it a bit too cumbersome?
Floor 3 Posted 2007-04-03 15:13 ·  中国 广东 广州 荔湾区 电信
银牌会员
★★★
Credits 1,206
Posts 517
Joined 2007-03-25 01:18
19-year member
UID 82819
Gender Male
Status Offline
Hehe, Windows provides us with NetMeeting. Why not use it?
知,不觉多。不知,乃求知
Floor 4 Posted 2007-04-04 09:39 ·  中国 福建 福州 电信
初级用户
Credits 92
Posts 26
Joined 2007-03-10 07:44
19-year member
UID 81291
Gender Male
Status Offline
It has been made very clear above. The purpose of writing this is to learn and practice relevant batch processing commands. It is hoped that it can provide a good case material for beginners. As for other software that can be used, it is not within the consideration scope of me writing this code.
Floor 5 Posted 2007-04-04 09:57 ·  中国 福建 福州 电信
初级用户
Credits 82
Posts 31
Joined 2007-03-19 10:38
19-year member
UID 82232
Gender Male
Status Offline
Thanks, the learning sample provided by the landlord!! Beginners need such things very much!!
Floor 6 Posted 2007-04-16 05:30 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
Such a good post actually sank.
Floor 7 Posted 2007-04-16 06:27 ·  中国 河南 新乡 联通
初级用户
Credits 88
Posts 40
Joined 2006-12-26 07:32
19-year member
UID 74591
Gender Male
Status Offline
Good stuff, I'll support it, can learn from it
Floor 8 Posted 2007-04-22 05:09 ·  中国 陕西 西安 电信
初级用户
★★
Credits 112
Posts 50
Joined 2007-04-15 00:59
19-year member
UID 85191
Gender Male
Status Offline
Take it back and study it, thank you the thread starter!!!
Floor 9 Posted 2007-04-22 08:07 ·  中国 福建 泉州 德化县 电信
初级用户
Credits 40
Posts 16
Joined 2006-12-03 05:20
19-year member
UID 72433
Gender Male
Status Offline
Support............Support
Floor 10 Posted 2007-04-22 12:51 ·  中国 河南 开封 联通
新手上路
Credits 18
Posts 9
Joined 2006-10-24 20:28
19-year member
UID 68071
Gender Male
Status Offline
Already bookmarked. Thanks. Learned a lot
Floor 11 Posted 2007-04-24 09:28 ·  中国 山西 晋城 移动
初级用户
铂金会员
Credits 44
Posts 21
Joined 2007-04-15 04:26
19-year member
UID 85218
Gender Male
Status Offline
Worth researching! Sample Text
Floor 12 Posted 2007-10-11 21:45 ·  中国 云南 红河哈尼族彝族自治州 电信
初级用户
Credits 29
Posts 15
Joined 2007-10-06 09:40
18-year member
UID 99007
Gender Male
Status Offline
Support, the LZ has worked hard
Floor 13 Posted 2007-10-12 00:45 ·  中国 广东 广州 白云区 电信
初级用户
★★
Credits 132
Posts 59
Joined 2007-08-23 21:24
18-year member
UID 95705
Gender Male
From GuangZhou
Status Offline
Learning...ing
Can you remove your advertisement?
Floor 14 Posted 2007-10-12 11:04 ·  中国 四川 成都 双流区 电信
初级用户
Credits 80
Posts 41
Joined 2007-10-05 14:44
18-year member
UID 98965
Gender Male
Status Offline
Got it~ Going back to study, thanks
http://user.qzone.qq.com/182365808
Floor 15 Posted 2007-10-12 21:20 ·  中国 江苏 盐城 建湖县 中移铁通
初级用户
Credits 90
Posts 32
Joined 2007-01-14 09:19
19-year member
UID 76479
Gender Male
Status Offline
Originally posted by jellord at 2007-4-4 09:39 AM:
It has been made very clear above. The purpose of writing this is to learn and practice related batch processing commands, and it is hoped to provide a good case material for beginners. As for other software that can be used, it is not within the consideration range of writing this code.


It's very useful and would be great to add it to the LAN Gomoku in batch processing.

Gomoku needs shared folders, needs to generate files, and can't chat.
Forum Jump: