User Input in DOS

March 3, 2005 at 07:43:36
Specs: win2k, 1gb

I want a prmpt in a batch file before runing. The logic is simple some thing like this:
@echo off
echo "Do you want to run the program?"
REM Needs Input (Y/N)
if (Input) = Y/y then
Goto Proceed
else
Exit
Can some one please help? Thanks



See More: User Input in DOS

Report •


#1
March 3, 2005 at 08:05:43

To solve your question is easy, but...

the solution is different under DOS kernel and NT systems as Windows 2K is. So as you declare to run Win 2K post in the right forum otherwise DOS guys may be offended.


Report •

#2
March 3, 2005 at 08:15:36

If it is easy why don't you post the answer please? I tried to post it on Win2k fprum and it does not let me... saying I can post only in one place... Can any one please help?

Report •

#3
March 3, 2005 at 08:33:39

Try this:

::**
@echo off > quit.bat
choice Do you want to proceed?
if errorlevel 2 quit

your prog
::**

Works for most flavors.

***
Hi IVO,

DOS guys get offended?

Well, who'd athought it.
**
Every time I get a need for 'tokens' or whatever I dig out one of the scripts of yours which I saved. I still can't get it through my thick head.


M2


Report •

Related Solutions

#4
March 3, 2005 at 08:53:06

Thank Mechanix2go, but my DOS does not like "Choice" Command... any thing else I can try?
TIA

Report •

#5
March 3, 2005 at 08:54:45

Hi Aftab
As IVO says there are some people who don't like you posting winXP/2000 questions. as the DOS Prompt in these operating systems is simulated MSDOS and not what can be called Real Mode MSDOS.

But to help you for now try this.

@echo off
set /p Input=
if /i "%Input%"=="y" (goto Proceed)
exit /b
:Proceed
echo Proceed

or this

if /i not "%Input%"=="y" (exit /b)
rem Here if Input=y/Y
echo Proceed


Report •

#6
March 3, 2005 at 09:01:15

Hi Mechanix2Go,

thank you for your words, you look a kind and practical person, but people in this Forum seems to hate NT related (although loosely) questions.

I do not agree with Fundamentalists (wherever they are), but I respect the dominant opinions too. That explains my previous post.


Report •

#7
March 3, 2005 at 09:04:24

Dtech10, Thank you so much!! It worked.

Report •

#8
March 3, 2005 at 09:12:28

Like so many things in life, it helps if you read the instructions. Those are pretty prominently located at the top of the forum page

It's not so much a matter of 'offending' anyone, it is a matter of site policy - and we've covered this ground before.

If you can answer the post - fine, no need to do a song & dance routine - but in reality Win2K questions should be posted in the Win2k forum (go figure) not in DOS, or Linux, or BeOS.

It's not that complicated.

You are here


Report •

#9
March 3, 2005 at 09:19:57

Aftab,

Which DOS does not like 'choice' and what does it not like about it?

***
IVO,

Yeah, good to get in sync with the crowd.

I'd rather try to help than pass out earaches.

Since set /p [or if /i] is working, as offered by dtech10, it apparently is NOT DOS.

AFAIK, 'choice has been included in every DOS and winders EXCEPT w2k.

So I guess he's using w2k cmd.exe


M2


Report •

#10
March 3, 2005 at 14:33:14

Hi
Maybe there should be a sub-section called "WinXP/W2k Command Prompt" as this is what Mr Gates calls it in Windows.
Then maybe that wouldnt work either.


Report •

#11
March 3, 2005 at 14:57:28

That has been suggested - for now we're trying to work with the newly named 'DOS Standalone' Forum and the fairly explicit instructions at the top of the page.

Bottom line is, it's a help forum - posts won't be removed if they can be answered, although it is in the OP's best interest to post in the appropriate forum.

Contributers in this forum shouldn't be expected to be knowledgeable in every command line interface going.

You are here


Report •


Ask Question