Sideway
output.to from Sideway
`-=[]โŸจโŸฉ\;',./~!@#$%^&*()_+{}|:"<>? ๐‘Ž๐‘๐‘๐‘‘๐‘’๐‘“๐‘”โ„Ž๐‘–๐‘—๐‘˜๐‘™๐‘š๐‘›๐‘œ๐‘๐‘ž๐‘Ÿ๐‘ ๐‘ก๐‘ข๐‘ฃ๐‘ค๐‘ฅ๐‘ฆ๐‘ง ร…โ€‰โˆ’โ€‚ร—โ€ƒโ‹…โˆ“ยฑโˆ˜๊žŠ๏นฆโˆ—โˆ™ โ„ฏ ๐”ธ๐”นโ„‚๐”ป๐”ผ๐”ฝ๐”พโ„๐•€๐•๐•‚๐•ƒ๐•„โ„•๐•†โ„™โ„šโ„๐•Š๐•‹๐•Œ๐•๐•Ž๐•๐•โ„ค๐ด๐ต๐ถ๐ท๐ธ๐น๐บ๐ป๐ผ๐ฝ๐พ๐ฟ๐‘€๐‘๐‘‚๐‘ƒ๐‘„๐‘…๐‘†๐‘‡๐‘ˆ๐‘‰๐‘Š๐‘‹๐‘Œ๐‘ โˆผโˆฝโˆพโ‰โ‰‚โ‰ƒโ‰„โ‰…โ‰†โ‰‡โ‰ˆโ‰‰โ‰Œโ‰โ‰ โ‰ก โ‰คโ‰ฅโ‰ฆโ‰งโ‰จโ‰ฉโ‰ชโ‰ซ โˆˆโˆ‰โˆŠโˆ‹โˆŒโˆ โŠ‚โŠƒโŠ„โŠ…โІโЇ ๐›ผ๐›ฝ๐›พ๐›ฟ๐œ€๐œ๐œ‚๐œƒ๐œ„๐œ…๐œ†๐œ‡๐œˆ๐œ‰๐œŠ๐œ‹๐œŒ๐œŽ๐œ๐œ๐œ‘๐œ’๐œ“๐œ” โˆ€โˆ‚โˆƒโˆ…โฆฐโˆ†โˆ‡โˆŽโˆžโˆโˆดโˆต โˆโˆโˆ‘โ‹€โ‹โ‹‚โ‹ƒ โˆงโˆจโˆฉโˆช โˆซโˆฌโˆญโˆฎโˆฏโˆฐโˆฑโˆฒโˆณ โˆฅโ‹ฎโ‹ฏโ‹ฐโ‹ฑ โ€– โ€ฒ โ€ณ โ€ด โ„ โ— สน สบ โ€ต โ€ถ โ€ท ๏น ๏น‚ ๏นƒ ๏น„ ๏ธน ๏ธบ ๏ธป ๏ธผ ๏ธ— ๏ธ˜ ๏ธฟ ๏น€ ๏ธฝ ๏ธพ ๏น‡ ๏นˆ ๏ธท ๏ธธ โœ   โ   โŽด  โŽต  โž   โŸ   โ    โก โ†โ†‘โ†’โ†“โ†คโ†ฆโ†ฅโ†งโ†”โ†•โ†–โ†—โ†˜โ†™โ–ฒโ–ผโ—€โ–ถโ†บโ†ปโŸฒโŸณ โ†ผโ†ฝโ†พโ†ฟโ‡€โ‡โ‡‚โ‡ƒโ‡„โ‡…โ‡†โ‡‡ โ‡โ‡‘โ‡’โ‡“โ‡”โ‡Œโ‡โ‡โ‡•โ‡–โ‡—โ‡˜โ‡™โ‡™โ‡ณโฅขโฅฃโฅคโฅฅโฅฆโฅงโฅจโฅฉโฅชโฅซโฅฌโฅญโฅฎโฅฏ
Draft for Information Only

Content

MS DOS Command: CHOICE
โ€ƒ Description
โ€ƒ Syntax
โ€ƒ Parameters
โ€ƒ Switches
โ€ƒ Remarks
โ€ƒโ€ƒ ERRORLEVEL parameters
โ€ƒ Examples

MS DOS Command: CHOICE

Reference from Microsoft MS-DOS cmd help

Description

Prompts the user to make a choice in a batch program. Displays a specified prompt and pauses for the user to choose from among a specified set of keys. You can use this command only in batch programs.

For more information on the ERRORLEVEL parameter, see CHOICE--Note and the IF command.

Syntax

CHOICE [/C[:]keys] [/N] [/S] [/T[:]c,nn] [text]

Parameters

text Specifies text you want to be displayed before the prompt. Quotation marks are necessary only if you include a switch character (/) as part of the text before the prompt. If you don't specify text, CHOICE displays only a prompt.

Switches

/C[:]keys Specifies allowable keys in the prompt. When displayed, the keys will be separated by commas, will appear in brackets ([]), and will be followed by a question mark. If you don't specify the /C switch, CHOICE uses YN as the default. The colon (:) is optional.
/N Causes CHOICE not to display the prompt. The text before the prompt is still displayed, however. If you specify the /N switch, the specified keys are still valid.
/S Causes CHOICE to be case sensitive. If the /S switch is not specified, CHOICE will accept either upper or lower case for any of the keys that the user specifies.
/T[:]c,nn Causes CHOICE to pause for a specified number of seconds before defaulting to a specified key. The values for the /T switch are as follows:
c Specifies the character to default to after nn seconds. The character must be in the set of choices specified in the /C switch.
nn Specifies the number of seconds to pause. Acceptable values are from 0 to 99. If 0 is specified, there will be no pause before defaulting.

Remarks

ERRORLEVEL parameters

The first key you assign returns a value of 1, the second a value of 2, the third a value of 3, and so on. If the user presses a key that is not among the keys you assigned, CHOICE sounds a warning beep (that is, it sends a BEL, or 07h, character to the console).

If CHOICE detects an error condition, it returns an ERRORLEVEL value of 255. If the user presses CTRL+BREAK or CTRL+C, CHOICE returns an ERRORLEVEL value of 0.

When you use ERRORLEVEL parameters in a batch program, list them in decreasing order.

Examples

What the user sees when you use CHOICE in a batch file

If you use the following syntax in a batch file,

choice /c:ync

the user sees the following when CHOICE is started:

[Y,N,C]?

If you add text to the syntax,

choice /c:ync Yes, No, or Continue

the user sees the following when CHOICE is started:

Yes, No, or Continue [Y,N,C]?

What the user sees if you leave out a prompt

If, as in the following example, you use the /N switch to leave out the prompt in a batch program,

choice /n Yes, No, or Continue?

the user sees only the text you specified when CHOICE is started:

Yes, No, or Continue?

What the user sees if you use the T switch

If you use the following syntax in a batch program,

choice /c:ync /t:n,5

the user sees the following when CHOICE is started:

[Y,N,C]?

If, after 5 seconds, the user hasn't pressed a key, CHOICE chooses N and returns an ERRORLEVEL value of 2. If the user presses a key before 5 seconds, CHOICE returns the value corresponding to the user's choice.

To have the option of defragmenting drive C when you start your computer, you could add the following lines to your AUTOEXEC.BAT file:

choice Defrag drive /ty,5

if errorlevel 2 goto SkipDefrag

defrag c:

:SkipDefrag

If you press N within 5 seconds, DEFRAG will not run and CHOICE returns an ERRORLEVEL value of 2. If you do not press N within 5 seconds, or if you choose Y, DEFRAG is run on drive C.

Using CHOICE in a batch program

The following batch program demonstrates using the CHOICE option to select one of three programs: MS-DOS Editor, Microsoft Anti-Virus, or Microsoft Backup.

Notice that the IF ERRORLEVEL statements are listed in decreasing order. MS-DOS will consider the IF statement true if the ERRORLEVEL parameter returned by CHOICE is greater than or equal to the parameter specified in the IF command.

@echo off

cls

echo.

echo A Microsoft Editor

echo B Microsoft Anti-Virus

echo C Microsoft Backup

echo.

choice /c:abc Choose an option

if errorlevel 3 goto MSBackup

if errorlevel 2 goto Msav

if errorlevel 1 goto Edit

 

:Edit

edit

goto End

 

:Msav

msav

goto End

 

:Msbackup

msbackup

goto End

 

:End


ยฉsideway

ID: 110700141 Last Updated: 7/22/2011 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 9

Culture

Chinese 1097

English 339

Travel 38

Reference 79

Hardware 55

Computer

Hardware 259

Software

Application 213

Digitization 37

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 290new

Unicode 504

HTML 66new

Common Color 1new

Html Entity (Unicode) 1new

Html 401 Special 1

CSS 65new

Selector 1

SVG 46

ASP.NET 270

OS 447new

MS Windows

Windows10 1new

.NET Framework 1

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Set 1

Logic 1

Algebra 84

Number Theory 207new

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2026 Sideway . All rights reserved Disclaimers last modified on 06 September 2019