Task

Create a variable with a user-defined name.

The variable name should not be written in the program text, but should be taken from the user dynamically.



See also
   Eval in environment is a similar task.


@echo off
setlocal enableDelayedExpansion
 
set /p "name=Enter a variable name: "
set /p "value=Enter a value: "

::Create the variable and set its value
set "%name%=%value%"

::Display the value without delayed expansion
call echo %name%=%%%name%%%

::Display the value using delayed expansion
echo %name%=!%name%!