Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理文件以使用.txt列表_Batch File - Fatal编程技术网

Batch file 批处理文件以使用.txt列表

Batch file 批处理文件以使用.txt列表,batch-file,Batch File,所以我正在写一个脚本,用我输入的设置启动一个程序。唯一的问题是,一些凭证变化非常快,我只想将它们全部定义到一个文本文件中,而无需每次手动将它们放入 @Echo off set /p Server= What Server would you like? (Input server here.) set Faction=new set DelayTime=20000 set Config=minecraftclient.ini CD C:\minecraft\%Faction% REM

所以我正在写一个脚本,用我输入的设置启动一个程序。唯一的问题是,一些凭证变化非常快,我只想将它们全部定义到一个文本文件中,而无需每次手动将它们放入

    @Echo off
set /p Server= What Server would you like? (Input server here.)
set Faction=new
set DelayTime=20000
set Config=minecraftclient.ini
CD C:\minecraft\%Faction%

REM start first 150/100/50

START MinecraftClient.exe %Config% User Pass %Server%
PING 1.1.1.1 -n 1 -w %DelayTime% >NUL
START MinecraftClient.exe %Config% User Pass %Server%
PING 1.1.1.1 -n 1 -w %DelayTime% >NUL
这是脚本的一个示例。我希望从一个单独的.txt文件中获取“User”和“Pass”,其中包含所有的User/Pass行。是否要让它读取每一行并像现在这样运行,直到完成文件?我对批处理不是很在行,所以如果我解释得不好,我很抱歉。该文件的格式为User:Pass,或者我可以去掉冒号(:),并在文件中设置为User-Pass,如下所示: testuser:testpass 或
testuser testpass在
CD

for  /f %%a in (userpass.txt) do (
 START MinecraftClient.exe %Config% %%a %%b %Server%
 PING 1.1.1.1 -n 1 -w %DelayTime% >NUL
)
假设文件
userpass.txt
包含

username1 password1
username2 password2
username3 password3
username4 password4
如果你想保留冒号,那么

for  /f "delims=:" %%a in (userpass.txt) do (

您的列表格式如何?你能发个样品吗?谢谢,你帮了我很多忙!