Solved

How to read registry value of dir path inside batch file

Posted on 2009-07-03
4
852 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Defining time in batch 7 57
Xcopy / Robocopy Question 7 65
Nmap how to find wich type of socks is this? 4 97
To check for the file in a batch script 8 33
When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

785 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