Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6903129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:53:14+00:00 2026-05-27T07:53:14+00:00

I am trying to query the install location of a program in the registry.

  • 0

I am trying to query the install location of a program in the registry. All I’m interested in is the location output.

This question has a partial solution, but it doesn’t quite help.
On Windows 7, the reg command outputs a stupid registry key header along with the value, as shown below:

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NSIS Unicode" /v InstallLocation

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NSIS Unicode
InstallLocation    REG_EXPAND_SZ    C:\Program Files\NSIS

First, is there a way to turn off the header and simplify the output?

At the command prompt, I can change the above to

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NSIS Unicode" /v InstallLocation | findstr InstallLocation

so that it returns me just the second line.

Now, if I am to use a FOR /F to parse this and get only the directory value, the FOR command fails saying | was unexpected at this time.

Here’s my batch file:

@for /f "tokens=2* delims=   " %%k in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NSIS Unicode" /v InstallLocation | findstr InstallLocation') do @echo %%k

So where am I going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:53:14+00:00Added an answer on May 27, 2026 at 7:53 am

    You must escape the | character using a caret (^).

    @echo off
    setlocal
    
    set KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NSIS Unicode
    set V=InstallLocation
    
    for /f "tokens=2* delims= " %%k in ('reg query "%KEY%" /v %V% ^| findstr "%V%"') do echo %%k
    

    this would return REG_SZ on my machine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to query a MySQL database using an array but I'm having trouble!
I am trying to query an .xls spreadsheet with VBScript, but I have run
I'm trying to query a table, fetch all records, and save the result as
I'm looking and trying to install my console application as service but not figured
I am trying to use the aspnet___regsql utility to install all the membership tables
I'm trying to execute a query which contains batched commands, and supposedly this wasn't
I have a query I've been trying to make, it's supposed to pull all
I already have a mysql server setup via MAMP. But when trying to install
This is my first module. I have been trying to successfully install my module
Trying to query a 'Favorites' model to get a list of items a user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.