1

so i was making a password maker. i made it so that it saved the pass word in a txt.

but in the en of the txt there was just a random number so it wouldent become 2 with the same name.

but it would not work for ever, so i thougt if i start on 1 in the txt name and every time it creates a new one it would add 1 to the variable.

so i came upp with the idea that if it svaves wich number the variable is then i could take that number and add upon that so i found code to input thing in a txt and i made it work=

set rfn=%random%
if %rfn% gtr 100 goto spara
echo this is the random password= %nua%-%nub%-%nuc%-%nud%-%nue%-%nuf%                >C:\Users\Jannis\Desktop\randomcode%rfn%.txt
echo text filen är sparad
pause

but as u see here the number it gives the text file on the end is random so i thought i would do the same thing thats upp there but in only one file and so the variable rfn.

the variable number would be saved into a text file and could be read later and add uppon so that the bat could save as many as i want.

so i serached for a script that reads a text file and i sure found one but theonly thing it did was typing whats in the text file in the bat it just echo it out so i tried this=

@echo off
color a
cls
cd "C:\Users\Jannis\Desktop\johans_map"
set hold=nummret.txt
echo %hold%
pause
exit

but the only thing that did was putting the name of the text fileto the variable so if any one know a better soulution for this or know how to put the inside of the text fileinto a variable that would be great.

i am really sorry for my english i am not native and i am young

thanks:)

2
  • Could you please put some more effort in building your sentences? There are so many typos and your sentences run too long to properly understand, you can expect more help if you formulate your questions and information properly. Good luck!
    – Anyone
    Jan 5, 2014 at 21:07
  • @anyone ok thanks and i am sorry for that Jan 5, 2014 at 21:10

1 Answer 1

0

If the file that will hold the last number or passwords generated is "numret.txt", and in this file there is only one line that contains that last number, the needed code to read this number is

for /f "tokens=*" %%f in (numret.txt) do set "hold=%%f"

This uses a for command to read the numret.txt file, processing line by line, and for each line assign its content to the variable hold

Once the %hold% variable has been updated, use

>numret.txt echo %hold%

to save the new last value

2
  • so is this a good test bat? like before i put it in the real bat? but i cant get itt to workif u could help? @echo off for /f "tokens=*" %%f in (noumber.txt) do set "hold=%%f" :start set /a rfn=%hold% cls set b=1 set /a rfn=%rfn%+%b% echo %rfn% echo %rfn% >C:\Users\%user%\Desktop\nummret.txt pause goto start @mc_nd Jan 6, 2014 at 0:47
  • @user3108088: 1- Use the same file to read counter and to save counter. 2- No need for %hold%, just use set "rfn=%%f" 3- No need for %b%, just use set /a "rfn+=1"
    – MC ND
    Jan 6, 2014 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.