Solved Batch - Different Variables for Each Token

November 7, 2012 at 10:20:38
Specs: Windows 7, 2GB
I'm trying to figure out how to set different variables for each token found in a reg key.

So let's say I find 5 drive letters, I would need to set %drive1% %drive2%, so on and so forth. Can anyone help?

See More: Batch - Different Variables for Each Token

Report •

November 7, 2012 at 12:27:02
Should be able to use a for f/ statement with a reg query. Whats the key you are examining. More importantly whats the REG QUERYoutput

:: mike

Report •

November 7, 2012 at 17:43:08
✔ Best Answer
::attempt to parse tokens
@echo off & setlocal enabledelayedexpansion
:: zz is a string representing the output of reg query, but like Mike said, we need
:: to know what key you are trying to dissect and its output format.
set zz=c: d: e:
set c=-1
call :split %zz%
for /L %%a in (0,1,%c%) do echo %%a==!x%%a!
goto :eof

if "%1" equ "" goto :eof
set /a c+=1
set x%c%=%1
goto :split

Report •

November 8, 2012 at 00:44:57
Some versions of reg give a funky output.

IIRR, some have a double CR or double LF.

Life is too important to be taken seriously.


Report •

Related Solutions

November 8, 2012 at 11:38:13
Thank you very much.

Report •

November 8, 2012 at 17:33:07
@M2, yeh, that's why I "qualified" my reply ;-) It seems like a lot of commands are going to unicode, or have zeros instead of spaces.
@astro, thank you, and you're welcome :-)

Report •

Ask Question