先选择一台电脑作为服务器,运行一下st.cmd,再将D:\ltserver设为共享
将chat.cmd中D:\ltserver改为\\服务器名\D:\ltserver
第一次先从http://www.namipan.com/d/d0f2ef32a0c523d809330c3392b9f2390bd347d200040000下载sleep程序,再运行chat.cmd;以后可直接运行chat.cmd
chat.cmd代码- @echo off
- setlocal enabledelayedexpansion
- title 登录窗口
- mode con cols=50 lines=10
- set server=D:\ltserver
- echo 请输入用户名及密码,如果没有该用户,将根据输入内容注册用户
- echo 用户名中不能有数字
- :sr
- set username=""
- set /p username=用户名:
- set mima=""
- set /p mima=密码:
- if exist %server%\users\%username% goto logon
- echo %mima%>>%username%
- copy .\%username% %server%\users\>>nul
- del %username%>>nul
- cls
- echo %username%用户注册成功,请登录
- goto sr
- :logon
- for /f %%p in (%server%\users\%username%) do set tps=%%p
- if "%tps%"=="%mima%" goto success
- cls
- echo 密码错误,请重新输入
- goto sr
- :success
- echo 登录中
- copy %server%\users\%username% %server%\online\
- start userlist.cmd %username% %server%
- start roomlist.cmd %username% %server%
- start suru.cmd %username% %server%
- exit
复制代码 st.cmd代码- set server=D:\ltserver
- md %server%\users
- md %server%\online
- md %server%\rooms
复制代码 userlist.cmd代码- @echo off
- title 用户列表
- mode con cols=20 lines=30
- set username=%1
- set server=%2
- :list
- cls
- echo 当前在线用户:
- dir /b %server%\online\
- sleep 5000
- goto list
- pause
复制代码 roomlist.cmd代码- @echo off
- title 聊天室列表
- mode con cols=20 lines=30
- set username=%1
- set server=%2
- :listro
- cls
- echo 已创建的聊天室:
- dir /b %server%\rooms
- set roomchoice=""
- sleep 5000
- goto listro
复制代码 suru.cmd代码- @echo off
- title 输入窗口
- mode con cols=31 lines=11
- set username=%1
- set server=%2
- :12
- set /p roomname=请输入你要进入的聊天室的名称。要创建一个聊天室,输入creatroom。输入tuichu将注销%username%并关闭软件:
- if %roomname%==creatroom goto creat
- if %roomname%==tuichu goto end
- if exist %server%\rooms\%roomname%\ltnr goto enter
- cls
- echo 没有叫%roomname%的聊天室
- goto 12
- :enter
- start chatroom.cmd %username% %server% %roomname%
- goto suruh
- :end
- del %server%\online\%username%
- taskkill /im cmd.exe
- taskkill /im cmd.exe
- taskkill /im cmd.exe
- taskkill /im cmd.exe
- taskkill /im cmd.exe
- taskkill /im cmd.exe
- taskkill /im cmd.exe
- exit
- :creat
- set roomname=""
- set /p roomname=给聊天室起个名字(名称中不能有数字):
- md %server%\rooms\%roomname%
- echo %username%>>%server%\rooms\%roomname%\creater
- attrib +h %server%\rooms\%roomname%\creater
- echo %roomname%创建成功,按任意键进入聊天室
- pause>>null
- start chatroom.cmd %username% %server% %roomname%
- :suruh
- cls
- set hua=""
- :tm
- cls
- set /p hua=输入你要讲的话,输入tuichu将退出该聊天室:
- if %hua%==tuichu goto exlt
- echo %username%说:>>%server%\rooms\%roomname%\ltnr
- echo %hua%>>%server%\rooms\%roomname%\ltnr
- goto tm
- :exlt
- rmdir %server%\rooms\%roomname%\%username%
- echo 您已退出聊天室%roomname%,请自行关闭聊天窗口
- pause
- cls
- goto 12
复制代码 chatroom.cmd代码- @echo off
- title 聊天窗口
- mode con cols=80 lines=35
- set username=%1
- set server=%2
- set roomname=%3
- md %server%\rooms\%roomname%\%username%>>null
- for /f %%l in (%server%\rooms\%roomname%\creater) do set leader=%%l
- cls
- :main
- echo 聊天室创建者:%leader%
- echo 该聊天室成员:
- dir /b %server%\rooms\%roomname%
- if exist %server%\rooms\%roomname%\ltnr goto xs
- echo.>>%server%\rooms\%roomname%\ltnr
- :xs
- attrib +h %server%\rooms\%roomname%\ltnr
- type %server%\rooms\%roomname%\ltnr
- sleep 3000
- cls
- goto main
复制代码
|