Discussion forum for all Windows batch related topics.
- Posts: 1
- Joined: 20 Dec 2018 09:45
Wrote batch file that offers a menu of choices in which the user can select multiple answers by entering numbers that corresponds with the answer separated by a space. I have to open a CMD first then run the script from there. When I do the first time I run it, the answers are not created. Run the script a second time from the same command window and it records the answers made the first time. Run a third and it records the answers from the second time and so on. If I just run the script without opening a command window it doesn't record anything. It should write users answers to a text file.
Code: Select all
SET/P MonDef=Does Monitor have any defects? (y or n): %=%
IF /i %MonDef%==n (
Set text=Does Monitor have any defects? There are no cracks or other physical defects in monitor.
) Else If /i %MonDef%==y (
Echo The display is cracked ---- 1
Echo The display is dim -------- 2
Echo The display is blurry ----- 3
Echo The display is discolored - 4
SET /p DisplayDef=Please type in the numbers of that corresponds with the display issues separated by a space: %=%
FOR %%i IN (%DisplayDef%) DO (
IF %%i==1 (
Echo Test 1
SET text=Monitor is cracked.
) ELSE IF %%i==2 (
Echo Test 2
SET text=Monitor is dim.
) ELSE IF %%i==3 (
Echo Test 3
SET text=Monitor is blurry
) ELSE IF %%i==4 (
Echo Test 4
SET text=Monitor is discolored.
Last edited by aGerman
on 20 Dec 2018 15:39, edited 1 time in total.
Reason: Please use code formatting.
- Posts: 3606
- Joined: 22 Jan 2010 18:01
- Location: Germany
Variables in a command line or a block of command lines enclosed in parentheses, are expanded to their values only once before the command line or block is executed. To avoid this early expansion you have to use delayed variable expansion by setting
For all variables defined or changed in a parenthesized block, replace the surrounding percent signs with exclamation points.