Saved Bookmarks
| 1. |
Solve : Making [Y/N] questions in batch files? |
|
Answer» the NT version is the one that you would want.3.1 or 3.5?Quote from: PirateSamir on January 26, 2009, 10:57:24 AM 3.1 or 3.5? Either, or NT4, or Win2K resource kit k thnx, i got 3.5 gonna learn to use it now Quote from: PirateSamir on January 26, 2009, 11:38:43 AM k thnx, i got 3.5Code: [Select]Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>choice /? CHOICE [/C[:]choices] [/N] [/S] [/T[:]c,nn] [text] /C[:]choices SPECIFIES allowable keys. Default is YN /N Do not display choices and ? at end of prompt string. /S Treat choice keys as case sensitive. /T[:]c,nn Default choice to c after nn seconds text Prompt string to display ERRORLEVEL is set to OFFSET of key user presses in choices. ok, 2 questions how would define your default choice? and what is errorlevel? (i've seen it quite oftenly in batch files) Quote from: PirateSamir on January 26, 2009, 11:55:00 AM ok, 2 questions Example Default choice is Y, timeout is 10 seconds Code: [Select]choice /C:YN /T:Y,10 Press Y or N echo errorlevel is: %errorlevel% If Y was PRESSED (or timeout occurred) the %errorlevel% will be 1 (because Y is choice 1) and if N was pressed %errorlevel% will be 2 (because N is the second choice) errorlevel is a system variable which is set by a program. Often 0=no ERROR, 1 or more means an error. Choice uses it to PASS the key pressed. Code: [Select]S:\>chtest1.bat Press Y or N [Y,N]?Y errorlevel is: 1 S:\>chtest1.bat Press Y or N [Y,N]?N errorlevel is: 2so can errorlevel be used for anything else?Quote from: PirateSamir on January 26, 2009, 12:49:58 PM so can errorlevel be used for anything else? Yes. Code: [Select]dir *.txt if %errorlevel% GTR 0 echo "No text files" Plenty of information if you use Google. ok thnx Quote from: hiteshsavla on January 23, 2009, 03:16:25 PM Code: [Select]@ECHO OFF Thanks hiteshsavla - Exactly what I required, saved me a lot of time. (I write batch files so infrequently these days that it takes time to get back into it) |
|