Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Alternative to Choice command for windows NT

449 views
Skip to first unread message

Tina Gollner

unread,
Dec 12, 2001, 1:11:00 AM12/12/01
to
Hi,

I am trying to figure out how to do a choice command in Windows NT.
My batch file in Windows 98 contains a lines as follows

::CHOICE TO CONTINUE OR NOT
choice /n Do you wish to Continue (Y or N) ?
if errorlevel 2 GOTO STOPPROG
if errorlevel 1 GOTO CHECK2

I have tried several attempts using the IF command and SET command .. but
can't seem to get it to work. I discovered that SET /p does not work on
NT.. so does anyone out there know how I can do a simple choice Y or N
without using the Choice command. Windows NT ...I know can use it .. but
the NT boxes I am putting the batch file on don't have it installed .. and
I know Choice can cause issues with NT.. so I don't want to use it at all..
Any help on this would be greatly appreciated.

Forever in your debt ...
Tina : )


Phil Robyn

unread,
Dec 12, 2001, 1:28:58 AM12/12/01
to

========begin file C:\CMD\DEMO\CONTINUE.CMD==================================
001. @echo off
002. ::
003. :: this is an example of displaying a prompt and reading
004. :: the user response into a variable
005. ::
006. setlocal
007. set msg=
008. :ask
009. echo.%msg%
010. echo.
011. set msg=
012. call rdstring response "Do you wish to Continue (Y or N) ?"
013. if not defined response goto :ask
014.
015. if /i "%response:~0,1%" EQU "Y" goto :Yes
016. if /i "%response:~0,1%" EQU "N" goto :No
017. set msg=[%response%] is not a valid response. Please reply with 'Y' or 'N'.
018. goto :ask
019. :Yes
020. echo OK, we decided we want to continue.
021. goto :EOF
022. :No
023. echo Nope, we decided not to continue.
024. goto :EOF
========end file C:\CMD\DEMO\CONTINUE.CMD==================================

========begin file C:\CMD\TEST\RDSTRING.CMD==================================
001. @echo off
002. ::
003. :: originally developed by Walter Zackery
004. ::
005. setlocal
006. set target=%1
007. set myprompt="""%2"""
008. set myprompt=%myprompt:""""=%
009. set myprompt=%myprompt:"""=%
010. echo.
011. echo %myprompt%
012. for /f "tokens=*" %%a in (
013. 'format/f:160 a: ^|find "..."') do set input=%%a
014. endlocal&set %target%=%input:~30%&goto :EOF
015. :EOF
========end file C:\CMD\TEST\RDSTRING.CMD==================================

--

u n z i p m y a d d r e s s t o s e n d e - m a i l

Herbert Kleebauer

unread,
Dec 12, 2001, 3:10:32 AM12/12/01
to
Tina Gollner wrote:
>
> Hi,
>
> I am trying to figure out how to do a choice command in Windows NT.
> My batch file in Windows 98 contains a lines as follows
>
> ::CHOICE TO CONTINUE OR NOT
> choice /n Do you wish to Continue (Y or N) ?
> if errorlevel 2 GOTO STOPPROG
> if errorlevel 1 GOTO CHECK2
>

@echo off
echo
Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>getkey.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY
Wv;ovBX2Gv0ExGIuht6>>getkey.com
echo L?p{KsUWK`LR0>>getkey.com

getkey.com
if errorlevel 89 if not errorlevel 90 echo Y key pressed
if errorlevel 121 if not errorlevel 122 echo y key pressed
if errorlevel 78 if not errorlevel 79 echo N key pressed
if errorlevel 110 if not errorlevel 111 echo n key pressed
del getkey.com

::--------------------------------------------------------

The source code:

; read character from keyboard and return ascii
; value as errorlevel

@=$100
eor.w r0,r0
trap #$16
move.b #$4c,m0
trap #$21

Herbert Kleebauer

unread,
Dec 12, 2001, 3:34:21 AM12/12/01
to
Sorry, there was a line wrap.

Tina Gollner wrote:
>
> Hi,
>
> I am trying to figure out how to do a choice command in Windows NT.
> My batch file in Windows 98 contains a lines as follows
>
> ::CHOICE TO CONTINUE OR NOT
> choice /n Do you wish to Continue (Y or N) ?
> if errorlevel 2 GOTO STOPPROG
> if errorlevel 1 GOTO CHECK2
>


@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>getkey.com

echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUYWv;ovBX2Gv0ExGIuht6>>getkey.com

Herbert Kleebauer

unread,
Dec 12, 2001, 3:43:49 AM12/12/01
to
Sorry for my destroyed posts, have canceled them (but don't know
if it works on all server). Switched back to Win98 and repost:


Tina Gollner wrote:
>
> Hi,
>
> I am trying to figure out how to do a choice command in Windows NT.
> My batch file in Windows 98 contains a lines as follows
>
> ::CHOICE TO CONTINUE OR NOT
> choice /n Do you wish to Continue (Y or N) ?
> if errorlevel 2 GOTO STOPPROG
> if errorlevel 1 GOTO CHECK2

@echo off


echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>getkey.com

echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>getkey.com

Outsider

unread,
Dec 12, 2001, 4:09:35 AM12/12/01
to
Herbert Kleebauer wrote:
>

...snipped

> @echo off
> echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>getkey.com
> echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>getkey.com
> echo L?p{KsUWK`LR0>>getkey.com
>
> getkey.com
> if errorlevel 89 if not errorlevel 90 echo Y key pressed
> if errorlevel 121 if not errorlevel 122 echo y key pressed
> if errorlevel 78 if not errorlevel 79 echo N key pressed
> if errorlevel 110 if not errorlevel 111 echo n key pressed
> del getkey.com
>

Cool. Thanks.

--
<!-Outsider//->
MS-DOS 6.22, Windows for Workgroups 3.11, Netscape Communicator 4.08

Tina Gollner

unread,
Dec 12, 2001, 10:58:24 AM12/12/01
to
Thanks for the help. I will try it out.
Tina : )

Herbert Kleebauer <kl...@unibwm.de> wrote in message news:<3C17168D...@unibwm.de>...

Bob Smith

unread,
Dec 14, 2001, 6:16:41 PM12/14/01
to
decide -30 /YN Run Segmant ?
if ERRORLEVEL 1 goto nolast

search for decide.exe

0 new messages