'Batch file - Loop through letters to set variables
I'm working on a batch file that sets the variables a through z and the default value should be y (for y or n). I can't find a way to loop through all the letters and set them all to "y" do loop a-z set=y
Currently, using
set a=y
set b=y
set c=y
echo.&echo.&echo Do you want to:
set /P a=Set a RESTORE point? Y/N?....
set /P b=Disable Search and Prefetch? Y/N?....
set /P c=Close all running programs? Y/N?....
Solution 1:[1]
The standard way:
for %%v in (a b c d e ... x y z) do set "%%v=y"
The smart-and-tricky way:
@echo off
setlocal EnableDelayedExpansion
for /L %%i in (97,1,122) do (
cmd /C exit /B %%i
set "!=ExitCodeAscii!=y"
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
