Jump to content

BREAKTHROUGH! Accepting user input in batch files


Recommended Posts

OK, after a bit more searching, I've come across exactly what we're looking for in a 1K freeware DOS utility - INPUT.COM by Horst Schaeffer

http://home.mnet-online.de/horst.muc/

You'll find INPUT.COM in the PBAT sction on the left. The syntax is painfully simple:

INPUT "Enter phrase here: " variablename

Will prompt the user to enter any alphanumeric string (words, spaces, etc.) and will save it in variablename after pressing enter. Sheesh, and I thought I was coming up with something new. :)

Folks, this will solve your input problems. But at least Adam got some good code out of it. Ignore my CHOICE code, I am going to use INPUT from now on.

Sigh,

JP

Link to comment
Share on other sites


getvar does the exact same thing as input.com.. haven't compared the two so maybe input.com may be a little smaller and user friendly.

I'm pretty sure set /p only works in Windows 2000 and XP with cmd.exe, not in a older, pure DOS environment, with command.com..

Link to comment
Share on other sites

@Zoster,

Thanks, but the SET /P doesn't work in DOS - that's what I was shooting for.

@RayOK

Yes, I think GETVAR is even made by the same guy (I saw it on his website as well), but it's alot larger than INPUT. I'm putting INPUT on a boot floppy with lots of other tools, so size matters.

I wonder what the WinME version of COMMAND.com would buy us, in terms of additional features. Anyone know?

JP

Link to comment
Share on other sites

I have a problem with the INPUT.COM program.

Here's my current test batch file:

@echo offUtilities\INPUT "Enter a new administrator name: " newadminecho %newadmin%pause

Now, when I run this, I get this output:

Enter a new administrator name: SomeAdminECHO is off.Press any key to continue

as you can see, it's not actually setting the variable. Even if I set the variable beforehand, it just retains it's old value. Can anyone help me with this?

Edit: Never mind.. just say this: Note: INPUT does not work under Win NT/2000/XP

Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...