How do I set a variable string as a variable?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
TheHunterManX
Posts: 54
Joined: 14 Aug 2015 05:59

How do I set a variable string as a variable?

#1 Post by TheHunterManX » 04 Jun 2017 12:02

I want to do the following:

Code: Select all

@echo off
set Input=Test
set /P Input=Type the var you want to set to 5(type nothing for Test):
call :Test %Input%
:Test
set %Input%=5
echo %Test%
pause
exit /b 0

This is an example, the file I'm working on has a LOT more call commands like the example. Is there a way for me to set the string as a variable?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How do I set a variable string as a variable?

#2 Post by aGerman » 04 Jun 2017 14:07

I don't even understand your example :? so I can only guess ...

Code: Select all

@echo off
set "Test=Input"
set /P "Input=Type the var you want to set to 5: "
set "%Input%=5"
echo %Test%
call echo %%%Test%%%
call call echo %%%%%%%Test%%%%%%%
pause

Steffen

Post Reply