spacesurfer Posted August 30, 2006 Posted August 30, 2006 I'm trying to use the choice command is a batch file so I can choose whether to install a particular program.However, it when it gets to that part of batch file, a dialog warning pops up telling me to close or ignore. It doesn't mention the command name but mentions the path to cmd.exe and some other file.Anyway, I choose ignore but choice.com doesn't work. It installs the program without my input.Is there a similar program that I can use to stop and ask if I want to install a program or not?Here's my choice script:ECHO Do you want to install Program?ECHO (Password required)ECHO.ECHO 1. Install ProgramECHO.ECHO 2. Skip installationECHO.ECHO.CHOICE /C:12 /N Please choose a menu option (1 or 2): IF ERRORLEVEL == 2 GOTO ENDIF ERRORLEVEL == 1 GOTO INSTALL:INSTALL"%cddrive%\Programs\program.exe":END
jdoe Posted August 30, 2006 Posted August 30, 2006 With Windows XP you don't need choice.com anymore. Search this forum or the web for the SET /P command. I'm sure you'll find what you need with full of examples.
LLXX Posted August 30, 2006 Posted August 30, 2006 Is that this error message? http://support.microsoft.com/default.aspx?...kb;en-us;324767It would help if you provided more information about the message.
spacesurfer Posted August 30, 2006 Author Posted August 30, 2006 LLXX. That's exactly what it was. Thanks for MS link.I'll try the set /p method first that someone above you mentioned.
LLXX Posted August 30, 2006 Posted August 30, 2006 Also you should note that there is no separate choice.com file, the CHOICE command is built into the command shell (cmd.exe) on XP.
spacesurfer Posted August 30, 2006 Author Posted August 30, 2006 Is that right? I've been using the choice.com from DOS. I'll give it a try.set /p works, however, you pointed me to a problem i may have with corrupted/missing config.nt or autoexec.nt.
spacesurfer Posted August 30, 2006 Author Posted August 30, 2006 well, that didn't work. it said choice is not recognized as an internal or external command or something like that.
Aegis Posted August 31, 2006 Posted August 31, 2006 (edited) I modified it a bit:ECHO Do you want to install Program?ECHO (Password required)ECHO.ECHO 1. Install ProgramECHO.ECHO 2. Skip installationECHO.ECHO.SET /P NewVar= Please choose a menu option (1 or 2)IF NewVar == 2 GOTO ENDIF NewVar == 1 GOTO INSTALL:INSTALL"%cddrive%\Programs\program.exe":END Edited August 31, 2006 by Aegis
spacesurfer Posted August 31, 2006 Author Posted August 31, 2006 Aegis, what I meant was that choice method did not work--it doesn't seem to be built-in as LLXX mentioned, unless there is some other way to call it.I got the set /p command to work just like you showed.Thanks.
mazin Posted August 31, 2006 Posted August 31, 2006 (edited) Also you should note that there is no separate choice.com file, the CHOICE command is built into the command shell (cmd.exe) on XP.Nope. It's not an internal command of cmd.exe. It does not exist on a Win-XP CD. You add it yourself.However, I did some attempts in the past to run it on XP.It works when explorer shell is loaded. There's a mess with the order of GOTO or SET under XP.SET /P is good enough. The only problem is taht there's no default answer that could be set after some designated time.@ spacesurferYou can use an application installer like W.A.I.T. or KTOOL. There are may apps for this purpose, however. Edited August 31, 2006 by mazin
jaclaz Posted August 31, 2006 Posted August 31, 2006 Yes, there is no way to use set /P with a default timeout selection.There are workarounds, see these:http://www.robvanderwoude.com/choice.html(using kixstart)or you can use CHOIX.COM, part of Horst Schaeffer utilities:ftp://ftp.sac.sk/pub/sac/utiltask/horst31.zipor the choice.exe that comes with the NT4 or 2000 Resource kit:http://www.ss64.com/nt/choice.htmlhere you can get it as a single file:http://www.petri.co.il/download_free_reskit_tools.htmhttp://www.dynawell.com/reskit/microsoft/win2000/choice.zip(21 kb download)Also, LLXX is "partially" right, starting with Server 2003 (not XP) CHOICE is in the OS not in the RK.jaclaz
mazin Posted August 31, 2006 Posted August 31, 2006 I'm sorry, jaclaz, to ask this. But, is one of those CHOICE.XXX supposed to work under XP?
gunsmokingman Posted August 31, 2006 Posted August 31, 2006 Here is a way to use a batch with a menu selection@Echo Off:MainCLSColor f3Mode 55,12Title CMD_Menu_TemplateEcho.Echo Type Yes To do somethingEcho.Echo Type No For something elseEcho.Echo Type Ok For another optionEcho.Echo Type Quit To exit this Echo.::::::::::: MENU SELECTION SET Choice=SET /P Choice=Type In A What You Would Like To Do -^> IF NOT '%Choice%'=='' SET Choice=%Choice:~0,9%IF /I '%choice%'=='Yes' GOTO Select1IF /I '%choice%'=='No' GOTO Select2IF /I '%choice%'=='Ok' GOTO Select3IF /I '%choice%'=='Quit' GOTO Select4ECHO This Is Not A Correct Selection -^> "%choice%" ^<-Echo Please try again.ping -n 3 127.0.0.1>nulgoto Main::::::::::: MENU 1 CHOICE:Select1CLS Color 19Mode 55,4 Title Selection 2Echo.Echo This was your reply -^> %choice% ^<-Echo.ping -n 3 127.0.0.1>nulgoto Main::::::::::: MENU 2 CHOICE:Select2CLS Color 6bMode 55,4 Title Selection 2Echo.Echo This was your reply -^> %choice% ^<-Echo.ping -n 3 127.0.0.1>nulgoto Main::::::::::: MENU 3 CHOICE:Select3CLS Color 9aMode 55,4 Title Selection 3Echo.Echo This was your reply -^> %choice% ^<-Echo.ping -n 3 127.0.0.1>nulgoto Main::::::::::: MENU 4 CHOICE:Select4CLS Color 5eMode 60,4 Title Good Bye And ExitEcho.Echo This was your reply -^> %choice%Echo.ping -n 3 127.0.0.1>nulCLSEcho.Echo Good ByeEcho.ping -n 3 127.0.0.1>nulgoto EOFExit:EOF
jaclaz Posted August 31, 2006 Posted August 31, 2006 (edited) I'm sorry, jaclaz, to ask this. But, is one of those CHOICE.XXX supposed to work under XP?Well, even original choice.com does work on XP. with a bit of tweaking (16 bit DOS subsystem).The CHOIX.COM is very similar (but smaller), never tested it in XP, but it works under 2K, so it should in XP too.The Win2K RK CHOICE.EXE does work perfectly in XP, without the problems detailed on http://www.ss64.com/nt/choice.htmlAvailabilityChoice.com was originally supplied on the Windows 95 install CD, however there are some issues with this version under NT - multiple concurrent invocations of CHOICE will clobber each other. CHOICE.com will also burn a lot of CPU's when in a wait state. The NT and 2000 Resource Kits contain CHOICE.EXE which behaves a lot better.In Windows 2003 CHOICE became a built-in command so it is no longer in the resource kit.I haven't tested it, but I reasonably presume that the Server 2003 version works in XP too.I gave the alternatives more as a "license" alternative than for real need, I mean even if it's not "elegant" from a programmer's point of view, WHO cares whether "when in wait state" CHOICE.COM eats CPU's cycles? jaclaz Edited August 31, 2006 by jaclaz
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now