I'm trying to read and split a reg_multi_sz entry in the registry in order to list all the instances of SQL Server installed in local and of course, it's not working, nothing is displayed.
Here my code :
@echo off
setlocal EnableDelayedExpansion
set KEY_NAME=HKLM\Software\Microsoft\Microsoft SQL Server
set VALUE_NAME=InstalledInstances
set strTemp=
for /F "usebackq skip=2 tokens=3" %%A IN (`reg query "%KEY_NAME%" /v "%VALUE_NAME%" /se #`) do (
set strTemp=%%A
:nextVar
for /F "tokens=1* delims=#" %%B in ("%strTemp%") do (
set strTemp=%%C
echo %%B
)
if defined %strTemp% goto nextVar
)
Do you have any ideas for the error?
Thank you. Sorry for the bad spelling.
You can't use a goto
within a loop and you need delayed expansion
implemented to set, change and use
a variable within a loop.