|What's the tempfile thing for?|
If you want to insert text at the top of a file you will need to rebuild it. That isn't just a batch problem. I just used the temp files as an example.
Well if they enter that password then they'll have to remember the whole thing...
That's not the point, the point is that something as simple as a typo can make the whole thing crash or even execute something unwanted. Simply type in the character > into one of the prompts, when you are using that variable the script will error out.
I thought the insert was the actual problem, now I'm not sure of what the problem even is, if I don't touch on it below can you please clarify what you need help with.
Set /p validation, the first thing is to check the variable isn't empty. Next is a check that the variable contains more than double quotes. Next strip out any double quotes.
At this point variable contains no double quotes, now it will test the input is at least 4 characters and then strip it to the first 20 chars.
set /p variable=Input:
if not defined variable goto label
if "%variable:"=%"=="" goto :label
if "%variable:~3,1%"=="" goto label