我正在为LAN联网的计算机聊天式的系统,并想为用户名,如果在使用或不使用支票。我不能让它工作,虽然,这是我在一个测试文件,这不工作...批次 - 检查用户输入的是一个文本文件,然后进行
@echo off
title Testing usercheck
setlocal EnableDelayedExpansion
set "user2="
set /p "user2="
find /c "%user2%" Users.twml
if %errorlevel% equ 1 goto yes
goto nope
:empty
cls
echo empty response, should not be triggered...
pause
goto end
:yes
cls
echo yes, you can use that
>> Users.twml echo %user2%
pause
goto end
:nope
cls
echo nope. that is taken... try again!
pause
goto end
:end
cls
echo.
echo End of testing file...
echo.
echo press any key to exit
pause>nul
exit
这需要用户输入,检查文件,看它是否在那里,如果它是,不能使用说,如果它不存在,它说可以使用和保存的名称到文本文件,以便其他人不能挑一样。然而,当我把它放在即时通讯做同样的事情不工作,节省了名文件的文件记录
ECHO is off.
正由这条线在这里
>> Users.twml echo %user2%
,而不是造成当我的主文件用户名输入的用户,但奇怪的是它在测试文件完美的作品,这是我的主文件,它不工作的部分。
@echo off
title Batch Chat Room
mode con: cols=83 lines=10
setlocal EnableDelayedExpansion
:startup
cls
echo Pick A UserName
echo 1-16 Character limit.
set "user2="
set /p "name2="
if "!name2!" == "" goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if "!name2!" == " " goto startup
if not "!name2:~16!" == "" goto over
find /c "%user2%" Users.twml
if %errorlevel% equ 1 goto conta
goto tryagaina
:conta
cls
echo yes, you can use that
>> Users.twml echo %user2%
pause
:: This pause is just for testing to add a wait here
copy /y NUL Connected.twml >NUL
copy /y NUL Directory.twml >NUL
attrib +h Connected.twml
attrib +h Directory.twml
cls
>> Connected.twml echo [System] %computername%:%username% Has joined as: %name2%
>> Directory.twml echo [System] %name2% Has joined the chat.
title Lightfoot Web - Batch ChatRoom - (User Typing) - (Username:%name2%)
goto A
:tryagaina
goto startup
这里是Users.twml一2个的内部行已写入由测试文件,其他人通过我的主要文件。
twml
bob
ECHO is off.
ECHO is off.
ECHO is off.
一开始我尝试FINDSTR,但无法得到它的工作,所以我用错误级别,因为我知道如何工作的非常好。但它不会将名称保存到使用我的主文件的文件中。林本难住了,因为Connected.twml和Directory.twml线都写自己的内容,只是Users.twml不会。
我投票作为题外话,因为它是关闭这个问题的[现有由同一个成员提问](https://stackoverflow.com/q/46396536/6738015)。 – Compo
TBG 1500,请不要尝试关闭自己的问题,以便再次问它,特别是没有连接的原始和任何响应。 – Compo