1

In CMD, I could do Set /P ASK=REPEAT and it would prompt the user for ASK. How do I do this in MSDOS Batch Files? (No, no the ones that run on NT, but the ones that run on MSDOS.)

Btw: 'Set /P' is an NT answer so it doesn't work.

:(

2
  • BTW: I know about the choice command, it is not what I am looking for.
    – Roke
    Oct 31, 2015 at 2:04
  • No version of MS-DOS came with a command that did this directly. @Dale's answer is the best you're going to get without a 3rd party program or writing a program in QBASIC or other language to do it. If you are trying to provide a boot time menu via AUTOEXEC.BAT, you may be able to do something similiar with the CONFIG.SYS menu directives - dos.rsvs.net/DOSPAGE/CONFMENU.HTM.
    – LawrenceC
    Nov 1, 2015 at 13:21

3 Answers 3

1

How about one of these. . .

Resource: http://www.msfn.org/board/topic/174005-prompt-for-variable-in-dos-71/

Example test.bas could use:C:\DOS71\QBASIC /run test.bas

REM Get the users input.
INPUT "Enter the system Serial Number"; reply$

REM Show the value of the reply.
PRINT reply$

REM Return to the system.
SYSTEM

OR

editvar -p "Enter the system Serial Number." INPUT
rem temp.exe /ss %INPUT%
md %INPUT%

UPDATE

Online Emulator: https://archive.org/details/msdos_qbasic_megapack

Resource: https://support.microsoft.com/en-us/kb/81360

Editor is a full screen text editor. QBasic is a program that reads instructions written in Basic and interprets them into executable computer code. 

The EDIT command starts Editor from the command prompt. QBASIC starts the QBasic Interpreter from the command prompt. Both Editor and QBasic may be executed with a switch or combination of switches to enhance or modify their performance. The following is a description of the switches available and how they affect Editor and QBasic:
    Switch   Description
   ------   -----------

   /B       Displays Editor or QBasic in black and white. This switch
            should be used to run Editor or QBasic on a monochrome
            monitor with a color graphics card. If the Editor or
            QBasic pull-down menus do not show the short cut keys on a
            CGA monitor, then use the /B switch when starting Editor
            or QBasic.

   /G       Use this switch with a CGA monitor to provide the fastest
            screen updating.

   /H       Use this switch to display the maximum number of lines on
            the screen that the monitor supports.

   /NOHI    Editor and QBasic are designed for 16 color monitors, but
            this switch allows Editor or QBasic to function on an
            eight color monitor. If Editor or QBasic pull-down menus
            do not show the short cut keys on a system that does not
            support bold characters, use the /NOHI switch when
            starting Editor or QBasic.

The following switches may be used only with QBasic:
   Switch     Description
   ------     -----------

   /EDITOR    Invokes Editor.

   /MBF       Converts the built-in functions MKS$,MKD$,CVS$, and CVD
              to MKSMBF$, MKDMBF$, CVSMBF, and CVDMBF, respectively.

   /RUN       Runs a specified Basic program before displaying it.

To start Editor with the /NOHI switch, type the following command at the command prompt:
edit /nohi
To start QBasic and run the program MYPROG.BAS, type the following at the command prompt:
qbasic /run myprog.bas
Reference(s): 

"MS-DOS User's Guide and Reference," versions 5.0 and 5.0a, pages 459, 547
4
  • I think you mean .bas . This is a .bas file. But still, thank you. Widely useful!
    – Roke
    Nov 1, 2015 at 1:27
  • How do I run it from the prompt?
    – Roke
    Nov 1, 2015 at 1:29
  • Qbasic /run var.bas (var.bas is the file name)
    – Roke
    Nov 1, 2015 at 1:31
  • You can run it directly from the command prompt with the '/run (file name)' argument
    – Roke
    Nov 1, 2015 at 13:13
2

This is an older way of doing input with an older DOS version. I don't have the older DOS version so its hard for me to test however I'll give you the code and the page that shows various ways of doing input for older versions of DOS. Here's the code.

ECHO Enter some input, and press Enter when ready . . .
ECHO ?[13;0;64;13p
COPY CON USRINPUT.TMP
ECHO ?[13;13p
CLS
ECHO You typed:
TYPE USRINPUT.TMP

Check out this site for more examples.

Batch files - Ask For User Input

2
  • I told you that /P doesn't work.
    – Roke
    Oct 31, 2015 at 2:18
  • I posted a new response that may fit the situation a bit better. Check out the new answer above.
    – Dale
    Oct 31, 2015 at 2:39
1

CHOICE is a command that exists in MSDOS 6.22 and I presume in 7.1 as well, although the exact syntax may vary. Example:

CHOICE /C:YN /T:N,10 Do you want to continue
IF ERRORLEVEL 2 GOTO :eof
ECHO You chose Y, continuing
:eof

/C option allows you specify permitted options /T option allows you to specify a default option and a timeout

Try CHOICE /? to get details for your DOS version.

1
  • Read my comment below the question.
    – Roke
    Oct 31, 2015 at 12:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .