Can you put form elements in a DOS batch file?
Can you put form elements in a batch file? I was curious when I saw it in Word 5.5 for DOS. I can't find out how to do it, but I know NOTHING about all that junk in an execut开发者_如何学Goable file for DOS. Can somebody please help me?
If you want to ask for free text in a batch file use:
SET /P UserName=What is your UserName?
This puts the user's response in an environment variable named UserName, which can be accessed with %UserName%
like this:
ECHO Hello, %UserName%. Welcome to planet Earth!
You can put any executable command in a batch file, hence you can do anything in a batch file. If you see anything terribly fancy (like windowing), you probably are looking at a third party program, rather than a command built into the command processor itself.
Off the top of my head, the closest thing to a form (something that you can select items from) that I can think of is the CHOICE
command. To find out how to use it, type this at a command prompt:
CHOICE /?
Here's the description...
This tool allows users to select one item from a list
of choices and returns the index of the selected choice.
Here are some syntax examples...
CHOICE /?
CHOICE /C YNC /M "Press Y for Yes, N for No or C for Cancel."
CHOICE /T 10 /C ync /CS /D y
CHOICE /C ab /M "Select a for option 1 and b for option 2."
CHOICE /C ab /N /M "Select a for option 1 and b for option 2."
And here's a full example:
CHOICE /C:ABCDN /N /T:10 /D:N /M:"Format drive A:, B:, C:, D: or None?"
REM Note that ERRORLEVEL handlers must be in decreasing order...
IF ERRORLEVEL 5 SET DRIVE=None
IF ERRORLEVEL 4 SET DRIVE=drive D:
IF ERRORLEVEL 3 SET DRIVE=drive C:
IF ERRORLEVEL 2 SET DRIVE=drive B:
IF ERRORLEVEL 1 SET DRIVE=drive A:
ECHO You chose to format %DRIVE%
精彩评论