Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS batching 1

Status
Not open for further replies.

johnaregan

Programmer
Mar 13, 2001
87
Hi
I'm looking to change all passwords in one go using the
net user command and a delimited text file containing all username and new passwords eg.

usr1:pwd1
usr2:pwd2
etc.

i know how to loop through the file:
for %%i in (list.txt) do ...

but i need to be able to pasre out the username and passwordsinto separte variables for the net user command.

any hints would be greatly appreciated
 
The example below will parse each line as it reads it. The tokens refer to value of the variables. Delims set the delimiter to ":". You can add multiple delimiters if you wish. %%i is explicitly assigned the value from token 1 which would be usrX in this scenario. %%j is implicitly assigned the value from token two which in this case is pwdX. You can set multiple tokens also and they will continue in alphabetical order. I hope this helps.

for /f "tokens=1,2 delims=:" %%i in (runtime.txt) do
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top