1

So I have a script that works, but at the end of the script I would like to record the date, time, %username%, and ask for a name (that will be typed by the user)

This would all go into a "log" file.

What I have is:

echo Data Secured by %username% On %date% At %time% >> testfile.txt

This works fine. But this is not asking for user input such as a name. I would like it to go like this:

-script will ask for "helper name?:" and will allow ANY THING to be typed here. It will then be inserted with the echo above to read:

 echo Data Secured by %username% & %helpername% On %date% At %time% >> testfile.txt

The result in the "log" file would be like this:

Data Secured by John & Jason on Fri 03/08/2013 At 15:29:27.19 

The helper name can be anything.

I thought I would use something like

set /p helpername=" ? "  

But this seems to be for YES NO answers or answers you can list, a persons name will change.

I hope this all makes sense....can someone please help.

Thank you!

1 Answer 1

1

You can use this to get the helper's name:

SET /P HelperName=Enter Helper Name:

And then this to save the data to the file:

ECHO Data Secured by %username% ^& %helpername% On %date% At %time%>>testfile.txt
Sign up to request clarification or add additional context in comments.

5 Comments

With just those two lines in the script The result is:L:\>SET /P HelperName=Enter Helper Name: Enter Helper Name:jason L:\>ECHO Data Secured by Owner & jason On Fri 03/08/2013 At 16:23:12.28 1>>tes tfile.txt Data Secured by Owner 'jason' is not recognized as an internal or external command, operable program or batch file. L:\>pause Press any key to continue . . .
Actually, I made one small edit. I just realized you used an &. It will need to be escaped with a ^.
What that is why it did not work for me? this whole time?? Jeez I could have made it say AND instead...arrg THANK YOU VERY MUCH!
I am new to this site, is there a thank you for you on this site? I tried to upvote but I can not until I have 15 of something.
Note there are many hidden bugs and limitations (such as if a user inputs special characters as their name), but in all it's right.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.