1

I have been having a real issue getting something that seems simple, but I can not seem to get a working answer.

Here is what I am doing:

  1. Setting a variable with a specific name: ex. set "select=computer1"
  2. I do a test and give that variable a value based on the result after using an if statement : ex set "%select%=1" This sets the variable %computer1% to 1
  3. I want to see what the value of %computer1% is however all I know is %select%.

Is there any way I can get the value of %computer1% when only knowing %select%? %select% knows the name of the new variable but I need to know its value without being able to directly call it by hard coded name.

I thought a pipeline might work but I can not seem to figure this out.

Thanks all, I appreciate your help.

2
  • set %select% will output computer1=1 Commented May 24, 2017 at 14:12
  • 1
    This type of management is described at this answer, although the topic is different... Commented May 24, 2017 at 14:22

1 Answer 1

4

You need another layer of parsing. You can do it:

with delayed expansion:

setlocal enabledelayedexpansion
echo !%select%!

without delayed expansion:

call echo %%select%%
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.