How to read registry value of dir path inside batch file

Hi all
I need to get variable with path of Firebird isntallation
i created bat file with code:

FOR  /F "tokens=3* " %%i IN ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Firebird Project\Firebird Server\Instances" /v "DefaultInstance"')   DO @echo %%i


unfortunately path is with space characters. Below the result of reg execution:

C:\>reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Firebird Project\Firebird Server\Instances" /v "DefaultInstance"

HKEY_LOCAL_MACHINE\SOFTWARE\Firebird Project\Firebird Server\Instances
    DefaultInstance    REG_SZ    C:\Program Files (x86)\Firebird\Firebird_2_0\

SO i need the result at the end of code like that FBDIR="C:\Program Files (x86)\Firebird\Firebird_2_0\"
elserpienteAsked:
Who is Participating?
 
AmazingTechConnect With a Mentor Commented:
I usually do it this way.


FOR /F "tokens=2,*" %%i IN ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Firebird Project\Firebird Server\Instances" /v "DefaultInstance" ^| Find /i "DefaultInstance"')   DO @Set FBDIR="%%j"

Open in new window

0
 
knightEknightCommented:
I'm not sure what you are asking, but if you need to remove spaces then do this:

FOR  /F "tokens=3*,delims="
0
 
knightEknightCommented:
correction - use a semi-colon:

FOR  /F "tokens=3*; delims="
0
 
elserpienteAuthor Commented:
I need to read path of FB into variable
now at example above it reads only  C:\Program Files instead of C:\Program Files (x86)\Firebird\Firebird_2_0\
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.