Computing.Net > Forums > Disk Operating System > Choice in batch files on NT4-DOS

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Choice in batch files on NT4-DOS

Reply to Message Icon

Name: Len
Date: September 6, 2002 at 08:03:08 Pacific
OS: WindowsNT4
CPU/Ram: pentium3, 128mb RAM
Comment:

I wrote a batch file with the CHOICE command in it but whenever the program gets to that command I get an error saying "the specified name is not recognised as an internal or external command." the same batch runs ok on a win95 machine.Can you help me please



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: September 6, 2002 at 09:54:39 Pacific
Reply:

CHOICE.COM is an external command, included by default on Windows 9x installation. However it does also work on NT systems, it's not present by default (you need the file CHOICE.COM). You can get the file and put on the directory from where the batch is been run or in a directory path, but that's not necessary. The NT batch scripting provides you tools so you don't need CHOICE.COM:

echo Choose [Y/N] ?
:choice
set /P CH=
if /I "%CH%"=="Y" goto yes
if /I "%CH%"=="N" goto nop
goto choice

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 2
Name: Len Mclean
Date: September 9, 2002 at 05:00:05 Pacific
Reply:

Thank you very much for your reply but I am very new to batch files (2 weeks actually).
I am learning to write them via a book so I don't understand or don't know where to put your reply in my batch file, here is a copy of my file

cls
@echo off


@echo Please choose a number
@echo.
@echo T. Trunk info
@echo S. Switchboard info
@echo V. Voicemail info
@echo E. Telstra 1810 info
@echo M. Mobile phones info
@echo P. TV Patching info
@echo OR 'X' to abort
@echo.

choice /c:TSVEMPX/T:X,20

if errorlevel==7 goto end
if errorlevel==6 goto tv
if errorlevel==5 goto mobile
if errorlevel==4 goto telstra
if errorlevel==3 goto voice
if errorlevel==2 goto switch
if errorlevel==1 goto trunk

:trunk
u:
cd pabxda~1
cd trunki~1
dir

:switch
u:
cd pabxda~1
cd switch~1
dir

:voice
u:
cd vmxinf~1
dir

:telstra
u:
cd pabxda~1
cd trunki~1
telstr~1.txt

:mobile
u:
cd pabxda~1
cd mobiles
mobile~1.xls

:tv
u:
cd pabxda~1
tvpatc~1.xls

:end
end

Also Where can I get a Choice.com from.
Thanks,Len


0

Response Number 3
Name: Secret_Doom
Date: September 9, 2002 at 11:08:26 Pacific
Reply:

1. All those @'s aren't necessary. Just give an initial "@echo off" (I recommend putting it on the first line) and all other commands will be hidden.

2. If each label should be executed upon a certain code, but only that label, not the ones below it, you should include a "goto end" on the end of each label.

Appart from that, the batch seems good to be run on Win9x/DOS. However, not on NT systems, since they don't have CHOICE.COM by default, as I've said.

You can get CHOICE.COM here:

http://www.geko.ch/batch/CHOICE.COM

If you choose to don't use CHOICE.COM, use that method I posted, this would be how to use it:

===== BATCH SCRIPT BEGIN =====
@echo off
cls
echo Please choose a number
echo.
echo T. Trunk info
echo S. Switchboard info
echo V. Voicemail info
echo E. Telstra 1810 info
echo M. Mobile phones info
echo P. TV Patching info
echo OR 'X' to abort
echo.
:choice
set /P CH=[T,S,V,E,M,P,X]?
if /I "%CH%"=="X" goto enf
if /I "%CH%"=="P" goto tv
if /I "%CH%"=="M" goto mobile
if /I "%CH%"=="E" goto telstra
if /I "%CH%"=="V" goto voice
if /I "%CH%"=="S" goto switch
if /I "%CH%"=="T" goto trunk
goto choice

:: Here goes the rest of the batch,
:: beggining from the :trunk label

===== BATCH SCRIPT END =====

You're probably using a DOS batch programming book, but you're on a NT system (which is NOT DOS). There are several differences between DOS batch and NT batch, I recommend you getting a more proper book.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 4
Name: Secret_Doom
Date: September 9, 2002 at 11:11:49 Pacific
Reply:

By the way, you don't need to buy a book. There are several tutotials and forums on the internet which you can use.

Also, the info screens from the commands on CMD.exe (NT's command interpreter) are great. For help on a certain command, type "cmd/?". Example:

SET /?

To view a list of cmds, type "HELP"

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 5
Name: Len
Date: September 10, 2002 at 07:17:30 Pacific
Reply:

Leonardo,
thanks, I used your method which worked and someone (Keith) sent me some programs from the NT4 resource kit which included the choice.exe which made my batch file worked in it's original form.
So thanks all for your time and efforts.
Regards,Len


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Choice in batch files on NT4-DOS

dos color in batch file? www.computing.net/answers/dos/dos-color-in-batch-file/9720.html

Simple copy batch file, please help www.computing.net/answers/dos/simple-copy-batch-file-please-help/11154.html

What does the % mean in batch files? www.computing.net/answers/dos/what-does-the-mean-in-batch-files/5925.html