Monday, 15 July 2013

batch file - How can I read and split a reg_multi-sz value in the Windows registry? -



batch file - How can I read and split a reg_multi-sz value in the Windows registry? -

i'm trying read , split reg_multi_sz entry in registry in order list instances of sql server installed in local , of course, it's not working, nil displayed.

here code :

@echo off setlocal enabledelayedexpansion set key_name=hklm\software\microsoft\microsoft sql server set value_name=installedinstances set strtemp= /f "usebackq skip=2 tokens=3" %%a in (`reg query "%key_name%" /v "%value_name%" /se #`) ( set strtemp=%%a :nextvar /f "tokens=1* delims=#" %%b in ("%strtemp%") ( set strtemp=%%c echo %%b ) if defined %strtemp% goto nextvar )

do have ideas of error ?

thank ;-)

sorry bad spelling.

you can't utilize goto within loop , need delayed expansion implemented set, alter , use variable within loop.

windows batch-file registry

No comments:

Post a Comment