Solved

How to read registry value of dir path inside batch file

Posted on 2009-07-03
4
854 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

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…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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