Computing.Net > Forums > Programming > Using the Choice Command

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Using the Choice Command

Reply to Message Icon

Original Message
Name: JayJay Programmer
Date: March 12, 2006 at 19:53:19 Pacific
Subject: Using the Choice Command
OS: Microsoft Windows XP Prof
CPU/Ram: 1.00GHz 320MB
Model/Manufacturer: Gateway
Comment:

Hi, I am need to use the choice command for my batch file but when I use it in Microsoft Windows XP Perfessional it says the choice command cannot be found? What do I need to do to use this command. Please Help!

Building my Computer.


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: March 12, 2006 at 21:02:11 Pacific
Reply: (edit)

Here



If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 2
Name: JayJay Programmer
Date: March 12, 2006 at 21:14:29 Pacific
Reply: (edit)

Thank you so much!

Building my Computer.
15 yr old Programmer.


Report Offensive Follow Up For Removal

Response Number 3
Name: JayJay Programmer
Date: March 12, 2006 at 21:38:57 Pacific
Reply: (edit)

Ok can you tell me what I am doing wrong.
I typed in my script:
@ECHO OFF
ECHO Choose One
ECHO 1.Credits.
ECHO 2.Visit my Site.
ECHO 3.Exit

CHOICE.EXE [/C[:]123] [/N] [/S]
IF ERRORLEVEL == 3 GOTO END
IF ERRORLEBEL == 2 GOTO SITE
IF ERRORLEVEL == 1 GOTO CRED

:END
exit

:SITE
START http:\\computertech21.tripod.com

:CRED
ECHO Made by James Little
ECHO 2006
ECHO E-mail me if you need help
ECHO comptech21@gmail.com

Can you tell me what I am doing wrong
all the scripts are running together.!

Building my Computer.
15 yr old Programmer.


Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: March 12, 2006 at 23:34:20 Pacific
Reply: (edit)

Hi JJ,

Where you see usage info like this:

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

The brackets usually indicate optional parameters. Don't include the brackets.

Here's a re-write:

::== jj2.bat
@ECHO OFF
ECHO Choose One
ECHO 1.Credits.
ECHO 2.Visit my Site.
ECHO 3.Exit

CHOICE.EXE /C:123 /N


IF ERRORLEVEL == 3 GOTO END
IF ERRORLEVEL == 2 GOTO SITE
IF ERRORLEVEL == 1 GOTO CRED

:END
echo exit
goto :eof

:SITE
echo START http:\\computertech21.tripod.com
goto :eof

:CRED
ECHO Made by James Little
ECHO 2006
:: DONE

Note that you need a "goto :eof" at the end of each section to keep it from "falling through".


NOTE: putting your email address in a forum is a bad idea. There are bots crawling here.

You may want to PM the site owner, Justin Weber, and ask him to delete this thread.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: March 12, 2006 at 23:43:57 Pacific
Reply: (edit)

You can simplify the branching.

:: jj6.bat
@ECHO OFF
ECHO Choose One
ECHO 1.Credits.
ECHO 2.Visit my Site.
ECHO 3.Exit

CHOICE.EXE /C:123 /N
goto :%errorlevel%

:1

ECHO Made by James Little
ECHO 2006
goto :eof
:2
echo START http:\\computertech21.tripod.com

:3
:: DONE


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal


Response Number 6
Name: rade
Date: March 13, 2006 at 01:39:43 Pacific
Reply: (edit)

Hey M2,

Now when you run the batch file, and press for example 1, you can barely see the credits come and then the window closes (when using cmd in WinXP). Wouldn't it be good to pause it after the credits show up so the user can read them? Only way I know how to do this i with the pause command:

:: jj6.bat
@ECHO OFF
ECHO Choose One
ECHO 1.Credits.
ECHO 2.Visit my Site.
ECHO 3.Exit

CHOICE.EXE /C:123 /N
goto :%errorlevel%

:1
ECHO Made by James Little
ECHO 2006
pause
goto :eof

:2
echo START http:\\computertech21.tripod.com

:3
:: DONE

Any other suggestions?

"Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies." - Linus Torvalds


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: March 13, 2006 at 01:46:36 Pacific
Reply: (edit)

Hi rade,

No opther way I know of.

I never think of clicking a bat. I always think in terms of typing it in. LOL


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 8
Name: rade
Date: March 13, 2006 at 02:49:32 Pacific
Reply: (edit)

Okay, thanks anyway!

"Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies." - Linus Torvalds


Report Offensive Follow Up For Removal

Response Number 9
Name: JayJay Programmer
Date: March 13, 2006 at 10:17:57 Pacific
Reply: (edit)

Hey guys thank you for the help here is what my executable script says (please note it is still in beta. I am still working out the kninks.)

@ECHO OFF

rem iPod Copier

rem Makes a new folder on the desktop

rem then copies all the music from iPod to the new folder

:MENU
title Main Menu
COLOR A
cls
ECHO ************************************
ECHO *
ECHO * Please choose a menu option.
ECHO *
ECHO * 1.Run iPod Copier.
ECHO * 2.Open Notes.
ECHO * 3.E-mail Me.
ECHO * 4.Visit my site.
ECHO * 5.View Credits.
ECHO * 6.Exit.
ECHO *
ECHO ************************************
CHOICE /C:123456 /N
IF ERRORLEVEL == 6 GOTO END
IF ERRORLEVEL == 5 GOTO CRED
IF ERRORLEVEL == 4 GOTO SITE
IF ERRORLEVEL == 3 GOTO MAIL
IF ERRORLEVEL == 2 GOTO NOTE
IF ERRORLEVEL == 1 GOTO RUN1

:END
exit
goto eof:

:CRED
CLS
COLOR B
TITle Credits
ECHO Made by James Little
ECHO March 12 2006
ECHO My Site: http:\\computertech21.tripod.com
ECHO E-Mail: comptech21@gmail.com
ECHO Made with Qick Batch File Complier 2.0.7.1
ECHO Press any key to return the menu.
PAUSE>NUL
GOTO MENU
goto eof:

:SITE
CLS
COLOR C
TITLE Opening Computer Tech
START http:\\computertech21.tripod.com
ECHO Press any key to return to the menu.
PAUSE>NUL
GOTO MENU
goto eof:

:MAIL
cls
title Opeing Mail Page.
COLOR D
ECHO Press any key to return to the menu.
pause>nul
goto menu
goto eof:

:NOTE
CLS
title Notes to remember.

COLOR 9

ECHO **********************

ECHO ***iPod Information***

ECHO **********************

ECHO Please make sure you have your iPod pluged in to your computer.
ECHO I have only tried this on a iPod Nano 2GB and 1GB. It still works on others.

pause

CLS

ECHO *****************

ECHO ***iPod Copier***

ECHO *****************

ECHO If you need any help e-mail me at comptech21@gmail.com
ECHO Please check later at http:\\computertech21.tripod.com for updates.

pause

CLS

ECHO ***********************

ECHO ***Color Infomation.***

ECHO ***********************

ECHO When the font color changes to Red, that means you need to press a key.

ECHO When the font color is Blue, that means you do not have to do anything,

ECHO it is loading.

ECHO (This is only when you run the iPod Copier)

COLOR 9

ECHO Press any key to return to the menu.

pause>NUL

GOTO MENU

goto eof:

:RUN1
CLS
COLOR 9

title iPod Copier

cls

title Creating Dir iPod_Music

"C:\Documents and Settings\All Users\Desktop"

md iPod_Music

dir

CLS

C:\Windows\desktop

md iPod_Music

dir

cls

title Getting Ready!

ECHO This will take a few moments.

ECHO Press any key to Continue.

COLOR C

Pause>NUL

COLOR 9

CLS

title Opening iPod_Music

START ipod_music

title Copying...First Folder

COPY E:\ipod_control\music\F00 ipod_music

CLS

COPY F:\ipod_control\music\F00 ipod_music

CLS

COPY G:\ipod_control\music\F00 ipod_music

CLS

COPY D:\Ipod_Control\Music\F00 iPod_Music

CLS

COPY Z:\Ipod_Control\Music\F00 iPod_Music

CLS

COPY X:\Ipod_Control\Music\F00 iPod_Music

CLS

COPY Y:\Ipod_Control\Music\F00 iPod_Music

CLS

title Going On

ECHO One Folder Copied

ECHO Would you like to copy another fold

ECHO If not close window.

ECHO If so Press any key to continue.

COLOR C

pause>NUL

COLOR 9

title Coping...Second Folder

CLS

COPY E:\Ipod_Control\Music\F01 iPod_Music

CLS

COPY F:\Ipod_Control\Music\F01 iPod_Music

CLS

COPY G:\Ipod_Control\Music\F01 iPod_Music

CLS

COPY D:\Ipod_Control\Music\F01 iPod_Music

CLS

COPY Z:\Ipod_Control\Music\F01 iPod_Music

CLS

COPY X:\Ipod_Control\Music\F01 iPod_Music

CLS

COPY Y:\Ipod_Control\Music\F01 iPod_Music

CLS

title Going On

ECHO Two Folders Copied

ECHO Would you like to copy another folder

ECHO If not close window

ECHO If so Press any Key to continue.

COLOR C

pause>NUL

COLOR 9

title Copying...Third Folder

CLS

COPY E:\Ipod_control\music\F02 ipod_music

CLS

COPY F:\Ipod_control\music\F02 ipod_music

CLS

COPY G:\Ipod_control\music\F02 ipod_music

CLS

COPY D:\Ipod_Control\Music\F02 iPod_Music

CLS

COPY Z:\Ipod_Control\Music\F02 iPod_Music

CLS

COPY X:\Ipod_Control\Music\F02 iPod_Music

CLS

COPY Y:\Ipod_Control\Music\F02 iPod_Music

CLS

title Done!

CLS

ECHO All folders Copied

pause
cls
Title Thank you.

color e

ECHO Thank you for using iPod Copier

ECHO Press any key to return to the menu.

PAUSE>NUL

GOTO MENU

GOTO eof:

Please tell me if I did somthing wrong. This is my first complete Batch and Exe.

Building my Computer.
15 yr old Programmer.


Report Offensive Follow Up For Removal

Response Number 10
Name: Mechanix2Go
Date: March 13, 2006 at 10:52:46 Pacific
Reply: (edit)

Hi JJ,

[1] you need:

goto :eof

NOT:

goto eof
OR
goto eof:

[2] You don't need:

goto :menu
goto :eof

because it will never get to the 2nd line

[3] If this:

"C:\Documents and Settings\All Users\Desktop"

is meant to change directories, what you need is:

cd "C:\Documents and Settings\All Users\Desktop"

[3] You evidently didn't get my drift about posting your email address.

[4] Not obvious why you are copying from 7 different drives. But hopefully you know.

[5] Your layout is neat and sensible so I think you're off to a good start.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 11
Name: JayJay Programmer
Date: March 13, 2006 at 11:37:56 Pacific
Reply: (edit)

I did get your drift about e-mails. that is a very old e-mail. I have ran this Batch servral times and it came out to be a success. The point of this program is to copy all the music from your iPod to a folder and I did screw up on the C:\documents and settings\all users\desktop I know I have been meaning to fix it. You where pondering about the coping from 7 drives well, When you plug a flash drive in depending how many you have plugged in determinds the Drive Letter. So if some one else is going to use this, I dont know which drive is going to pop up. If that made any sense then you will understand where I am comming from.

Thank you for your Time M2.

Building my Computer.
15 yr old Programmer.


Report Offensive Follow Up For Removal

Response Number 12
Name: JayJay Programmer
Date: March 13, 2006 at 11:43:06 Pacific
Reply: (edit)

Once I get done I will post it here so you can check it out.

Building my Computer.
15 yr old Programmer.


Report Offensive Follow Up For Removal

Response Number 13
Name: Mechanix2Go
Date: March 13, 2006 at 11:53:29 Pacific
Reply: (edit)

With XP [and other NT] you can assign drive letters so they don't go squishing around.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 14
Name: JayJay Programmer
Date: March 13, 2006 at 12:16:14 Pacific
Reply: (edit)

Lets say I have a flash Drive we will call it Flashy. Now my other flash drive is named Linky. So I take Flashy and plug this little guy in first his Drive title is F:\
now with flashy still in I plug in Linky, he is G:\ now. But if I plug in Linky in First he is named F:\ not g:\ any more but F:\ and when I plug in Flashy he is G:\ not F:\. Do you get what I am saying Mr.M2 I hope you do. If you don't lets just drop this subject. You are very advance and I know you know what I am talking about I am just not telling very clearly.

Thank you M2 again!

Building my Computer.
15 yr old Programmer.


Report Offensive Follow Up For Removal

Response Number 15
Name: Mechanix2Go
Date: March 13, 2006 at 12:26:09 Pacific
Reply: (edit)

"Lets say I have a flash Drive we will call it Flashy. Now my other flash drive is named Linky."

I like your style.

You plug them both in and go to:

control panel > admin tools > storage mgmt

and assign them, let's say, t: and u:

End of problem.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 16
Name: JayJay Programmer
Date: March 13, 2006 at 14:36:49 Pacific
Reply: (edit)

oh ok thanks

Building my Computer.
15 yr old Programmer.


Report Offensive Follow Up For Removal

Response Number 17
Name: JayJay Programmer
Date: March 13, 2006 at 14:37:20 Pacific
Reply: (edit)

Can I write a script that does this for me?

Building my Computer.
15 yr old Programmer.


Report Offensive Follow Up For Removal

Response Number 18
Name: Mechanix2Go
Date: March 13, 2006 at 21:54:13 Pacific
Reply: (edit)

I certainly can't; maybe somebody can.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal






Post Locked

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


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software