Download Editv14.zip and unzip it to a folder that is in your PATH.
EditV32 and Choose32 are Win32 console programs that are designed to allow user input in shell scripts (batch files). The download also includes MS-DOS version of both programs, EditVar and Choose, that may be useful on DOS bootable media.
EditV32 works by obtaining the contents of an environment variable and presenting it for interactive editing. If you make any changes to the variable's contents and press Enter, EditV32 writes the changed variable to the parent environment of the program that started it (usually Cmd.exe). EditV32 requires Windows NT 4.0 or later; for Windows 9x/Me, use the MS-DOS version.
EditV32 is similar to the Cmd.exe Set /p command in Windows 2000 and later, but it may be preferable for the following reasons:
- It allows you to edit a variable, not just set one.
- It can limit the length of the typed variable.
- It can mask the typed input for simple password security.
- It can limit typed input to numbers only.
- It offers a timeout feature (useful when a script needs to run unattended).
- It automatically "escapes" reserved shell characters in variables it creates.
- It provides useful exit codes: For example, an exit code of 4 means that the user pressed Ctrl-C to abort.
- It comes with an MS-DOS version that works in Windows 9x/Me as well as on MS-DOS boot media.
Choose32 is similar to the Microsoft Choice tool, but it has more features. Here are some reasons why it might be preferable to Choice:
- It doesn't beep when the user makes an invalid choice.
- It offers a "default key" feature, which lets a user press Enter to select a default choice.
- It comes with a DOS version (useful for MS-DOS boot media).
- The Win32 version's timeout feature doesn't get confused when you run multiple instances in separate console windows (this was a problem with earlier Win32 console versions of Microsoft's Choice tool).
- It can suppress the display of the user's choice.
- It offers a "line input" mode where the user must press Enter after making a choice.
When you open a CMD.EXE prompt and type choose32 /?, you receive:
Choose32 1.3 - (C) 2006 by Bill Stewart (firstname.lastname@example.org) Allows selection of a choice from a list of choices. Usage: Choose32 \[-c choices\] \[-d x\] \[-l\] \[-n\] \[-p prompt\] \[-q\] \[-s\] \[-t x,n\] -c choices Specifies valid choices (default is 'YN'). -d x Choose 'x' if Enter is pressed. -l Use line input mode (must press Enter after making a choice). -n Do not display the list of choices. -p prompt Prompt the user with 'prompt' (enclose in quotes if it has spaces). -q Do not display the choice that was selected (ignored with -l). -s Choices are case sensitive. -t x,n Choose 'x' automatically if no choice made within 'n' seconds. Without -c, the default choices are 'YN' (or 'yn' with -s). The program's exit code will be the position of the choice in the list. If Ctrl-C is pressed, the exit code will be 255.When you open a CMD.EXE prompt and type editv32 /?, you receive:
EditV32 1.3 - (C) 2006 by Bill Stewart (email@example.com) Allows interactive editing of environment variables. Usage: EditV32 \[-b\] \[-l len\] \[-m\] \[-n\] \[-o\] \[-p prompt\] \[-t n\] \[-u\] var -b Place cursor at the beginning of the input string. -l len Allow no more than 'len' characters (1 to 2047). -m Masked input ('*' appears for each typed character). -n Allow only numeric input (0-9). -o Start overtype mode. -p prompt Prompt the user with 'prompt' (enclose in quotes if it has spaces). -t n Assume Enter was pressed if nothing typed in 'n' seconds. -u Force entered characters to uppercase. var The environment variable's name (required). Exit codes: 1 Error on the command line 2 Input line was blank 3 Environment variable was not changed 4 Program aborted with Ctrl-CNOTE: The Choose32.txt and Editv32.txt files contain addition usage information.