General discussion

Locked

NT Batch file: Get User Input

By stephan.bakker ·
Hi,

I have problems to get a user input into a nt batch file, like a username/password.

For win2k u can use the Set /p option to get user input.

The only option i can see to get some user input, is to use the %1, %2, etc var. but i want to ask for the user input during the batch file and not infront.

I know its pretty difficult to get user input into a batch file running under windows NT.

there for i hope sameone knows a beter way to get the user Input.

best regards,

Stephan Bakker

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

NT Batch file: Get User Input

by SyscoKid In reply to NT Batch file: Get User I ...

CHOICE.EXE comes wih the Resource Kit and allows you to ask for user input. The syntax is:

CHOICE [/C[:]choices] [/N] [/T[:]c,nn] [text]

/C[:]choices Specifies allowable keys. Default is YN
/N Do not display choices and ? at end of prompt
/S Treat choice keys as case sensitive.
/T[:]c,nn Default choice to c after nn seconds
text Prompt string to display

ERRORLEVEL is set to offset of key user presses in choices.

Collapse -

NT Batch file: Get User Input

by stephan.bakker In reply to NT Batch file: Get User I ...

This option is only useable for user input if a single keystroke is needed, like 1, 2, 3, A, B, etc and not for multiple Characters like a "username" or "password"

But thank u for your reply.

Collapse -

NT Batch file: Get User Input

by BeerMonster In reply to NT Batch file: Get User I ...

Hi,
I've only just found this by playing on my XP Pro machine, so I hope it works on NT. Like most workarounds it's not ideal.

If you use

more > user.txt

then the user can put in details that will be copied into the user.txt file. They will need to enter CTRL and Z to end the input, so for example they would need to type

theirusername
theirpassword
^Z - note this is the CTRL and Z combo in a command window. Also note that each entry is on a separate line - IE they need to press enter after each entry. You could then parse the pass.txt file (using a for loop) to extract the username and password. Like I say, it's a hack around. A far better option would be to use VBScript, It takes a little while to get into (and I mean a little while - with a decent book you could have your script written in a day) but is is SO more powerful, things like input are easy in vbscript. Hope it works....

Collapse -

NT Batch file: Get User Input

by stephan.bakker In reply to NT Batch file: Get User I ...

The question was auto-closed by TechRepublic

Collapse -

NT Batch file: Get User Input

by Joseph Moore In reply to NT Batch file: Get User I ...

Run KiXtart scripts. There is a GETS command that will "Reads a line of characters from the keyboard until the <enter> key is pressed, and stores the result in a variable."
They are an alternate to BAT files.
http://kixtart.org/index.html

hope this helps

Collapse -

NT Batch file: Get User Input

by stephan.bakker In reply to NT Batch file: Get User I ...

The question was auto-closed by TechRepublic

Collapse -

NT Batch file: Get User Input

by stephan.bakker In reply to NT Batch file: Get User I ...

This question was auto closed due to inactivity

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums