Windows Package Selection Command for Windows XP and 2003

Is there a way to invite users to enter (i.e., Yes / No) from a Windows script package that runs on XP and Windows 2003 servers? It seems that some commands (i.e. Choice) work only on one OS, and not on others.

+6
windows cmd windows-xp batch-file
source share
6 answers

Use the SET command with the / P switch.

+8
source share
SET /P RESULT=Y or N? ECHO %RESULT% 
+6
source share

Note that the SET /P command does not support all the same functions as the CHOICE command. Namely:

  • It does not restrict user access to a valid value.
  • User must press enter
  • You need to check the differences in the case (for example, β€œA” versus β€œa”)
  • It is not possible to set a specific selection by default after a certain time.

For these reasons, I still prefer to use the CHOICE command rather than the SET /P command. To do this, you just need to include CHOICE.COM along with your batch file. You can download CHOICE.COM from Microsoft through the optional MS-DOS 6.22 drive. Here is the link:

http://support.microsoft.com/kb/117600

+6
source share

This basically mimics the selection, you will need to put it as a routine in your batch file. I also prefer the choice, but I need something portable that will work on Windows XP.

You can then change this to accept other β€œoptions”, however it will work as case-insensitive and repeat the request until the user explicitly enters Y, y, N or n.

 :yesorno set /p choice=%2 if /i NOT %choice% == n ( if /i NOT %choice% == y goto yesorno ) set "%~1=%choice%" goto :eof 

Then you call this routine with:

 call :yesorno answer "Do you want to continue? [Y/n]: " 

It has worked very well for me so far.

+2
source share

For example, you can use this:

 SET /P ANSWER=y OR n? If "%answer%"=="y" goto yes If "%answer%"=="n" goto no 

Enjoy it!

+1
source share

Windows Millenium CHOICE.COM works fine for me under XP SP3. However, my Hungarian language, but you can probably find its original English version, for example, the search for "windows millenium ebd".

http://s000.tinyupload.com/index.php?file_id=57468192666746678653

-one
source share

All Articles