Jump to content

Recommended Posts

Posted

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 Program
ECHO.
ECHO 2. Skip installation
ECHO.
ECHO.
CHOICE /C:12 /N Please choose a menu option (1 or 2):
IF ERRORLEVEL == 2 GOTO END
IF ERRORLEVEL == 1 GOTO INSTALL

:INSTALL
"%cddrive%\Programs\program.exe"

:END


Posted

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.

:hello:

Posted

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.

Posted

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.

Posted (edited)

I modified it a bit:

ECHO   Do you want to install Program?
ECHO (Password required)
ECHO.
ECHO 1. Install Program
ECHO.
ECHO 2. Skip installation
ECHO.
ECHO.
SET /P NewVar= Please choose a menu option (1 or 2)
IF NewVar == 2 GOTO END
IF NewVar == 1 GOTO INSTALL

:INSTALL
"%cddrive%\Programs\program.exe"

:END

Edited by Aegis
Posted

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.

Posted (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.

@ spacesurfer

You can use an application installer like W.A.I.T. or KTOOL. There are may apps for this purpose, however.

Edited by mazin
Posted

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.zip

or the choice.exe that comes with the NT4 or 2000 Resource kit:

http://www.ss64.com/nt/choice.html

here you can get it as a single file:

http://www.petri.co.il/download_free_reskit_tools.htm

http://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

Posted

Here is a way to use a batch with a menu selection

@Echo Off

:Main
CLS
Color f3
Mode 55,12
Title CMD_Menu_Template
Echo.
Echo Type Yes To do something
Echo.
Echo Type No For something else
Echo.
Echo Type Ok For another option
Echo.
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 Select1
IF /I '%choice%'=='No' GOTO Select2
IF /I '%choice%'=='Ok' GOTO Select3
IF /I '%choice%'=='Quit' GOTO Select4

ECHO This Is Not A Correct Selection -^> "%choice%" ^<-
Echo Please try again.
ping -n 3 127.0.0.1>nul
goto Main

::::::::::: MENU 1 CHOICE
:Select1
CLS
Color 19
Mode 55,4
Title Selection 2
Echo.
Echo This was your reply -^> %choice% ^<-
Echo.
ping -n 3 127.0.0.1>nul
goto Main

::::::::::: MENU 2 CHOICE
:Select2
CLS
Color 6b
Mode 55,4
Title Selection 2
Echo.
Echo This was your reply -^> %choice% ^<-
Echo.
ping -n 3 127.0.0.1>nul
goto Main

::::::::::: MENU 3 CHOICE
:Select3
CLS
Color 9a
Mode 55,4
Title Selection 3
Echo.
Echo This was your reply -^> %choice% ^<-
Echo.
ping -n 3 127.0.0.1>nul
goto Main

::::::::::: MENU 4 CHOICE
:Select4
CLS
Color 5e
Mode 60,4
Title Good Bye And Exit
Echo.
Echo This was your reply -^> %choice%
Echo.
ping -n 3 127.0.0.1>nul
CLS
Echo.
Echo Good Bye
Echo.
ping -n 3 127.0.0.1>nul
goto EOF
Exit
:EOF

Posted (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.html

Availability

Choice.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?

:blink:

jaclaz

Edited by jaclaz

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...