Reputation: 5
So I am writing a script that will launch a program with the settings I put in. The only problem is, some of the credentials change very rapidly, and I want to just define all of them into a text file without having to manually put them in each time.
@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
This is an example of the script. I was it to take the "User" and "Pass" from a seperate .txt file with all the user/pass in rows. Is there anyway to have it read through each line and run it like this is right now until it finishes the file? I'm not very good at batch, so sorry if I didn't explain it very well. The file would be formatted either User:Pass or I can get rid of the colon (:) and just make it User Pass in the file like this: testuser:testpass or testuser testpass
Upvotes: 0
Views: 509
Reputation: 80211
After the 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
)
Assuming that the file userpass.txt
contains
username1 password1
username2 password2
username3 password3
username4 password4
If you want to retain the colons, then
for /f "delims=:" %%a in (userpass.txt) do (
Upvotes: 1