For /f Need help
Posted: 30 Oct 2009 08:17
I have
Which produces:
ALLDATASC\0SQLEXPRESS\0\0
I am trying to get:
ALLDATASC
SQLEXPRESS
...and so on.
Code: Select all
@ECHO OFF
for /f "skip=2 delims=" %%a in ('
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server"
') do (
for /f "skip=4 tokens=2,* delims= " %%b in ('
2^>nul reg query "%%a" /v "InstalledInstances"
') do (
if not errorlevel 1 (
Echo %%c
)
)
)
Pause
Which produces:
ALLDATASC\0SQLEXPRESS\0\0
I am trying to get:
ALLDATASC
SQLEXPRESS
...and so on.