Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to read registry value of dir path inside batch file

Posted on 2009-07-03
4
Medium Priority
?
859 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 1000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

971 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