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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to allow user input to script ?

Status
Not open for further replies.

muneco

Programmer
Nov 6, 2000
28
US
Is there a way to write an NT script that allows user input?

What I mean is that I would like to interactively prompt the user for input (say, their name or a transaction number), and capture their response in a variable.

I would appreciate any help.
 
The only way to read lines of input from the command line is using the COPY command.
for example:

echo Enter filename, followed by CTRL+Z:
copy con filename.tmp

The COPY command stops reading when you press ctrl-z, you will then find the contents of what the user pressed in filename.tmp which you should then parse using a FOR /F command.

you do not have much control over this and it's usually better to provide the user with a limited choice of what they can choose and use the CHOICE command.

Ciao
Gary

 
of course you'd need to copy choice.com from a 9x/ME installation as it doesn't come with NT.
 
Thanks to both of you for your helpful replies. I had read about the choice command but couldn't get it to run (duh!) and the info about the copy command will be helpful too.

Thanks again and best wishes!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top