Solved

How to read registry value of dir path inside batch file

Posted on 2009-07-03
4
848 Views
Last Modified: 2012-05-07
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\"
0
Comment
Question by:elserpiente
  • 2
4 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 24772023
I'm not sure what you are asking, but if you need to remove spaces then do this:

FOR  /F "tokens=3*,delims="
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 24772025
correction - use a semi-colon:

FOR  /F "tokens=3*; delims="
0
 

Author Comment

by:elserpiente
ID: 24772313
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
 
LVL 21

Accepted Solution

by:
AmazingTech earned 250 total points
ID: 24772936
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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now