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 8730261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:59:09+00:00 2026-06-13T08:59:09+00:00

I am trying to delete some registry keys in a batch file I made.

  • 0

I am trying to delete some registry keys in a batch file I made.

I found the following code on here and it works good until it hits the REG DELETE

for /F "tokens=1,*" %%a in ('REG QUERY "%KEY%" ^| findstr /I /C:"%VALUE%"') do (REG DELETE %KEY% /v %%a)

The value is located under [HK_CLASSES_ROOT\Installer\Assemblies\Global]
As you can probably see, most the values here have quotes in them for example:

ADODB,fileVersion="7.10.2346.0",version="7.0.3300.00",culture="neutral",publicKeyToken="B03F5F7F11D50A3A"

That’s not exactly what I want to remove but it is pretty close.

So if I echo %%a it shows the value name as it is in the regedit with the quotes and everything.
But as soon as it goes through REG DELETE (right now it asks for confirmation) the quotes are not there, so if I hit yes, it tells me it can’t find the key.

Obviously it can’t since it didn’t parse the same thing it found initially. I’ve been trying to find a solution but I havn’t found anything so far helping me in the right direction. I know I could probably do the same in vbs but this is a line long whereas in vbs it would be a lot longer to do the same job.

Any help is appreciated, if you need more info ask away, I just started messing around with batch file. I made this because I needed to automate the installation process of all the dependencies for my school project each time I work at school.(The computers are ghosted)

Thanks

  • 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-06-13T08:59:12+00:00Added an answer on June 13, 2026 at 8:59 am

    Note – Your "tokens=1,*" is not needed since you are only using the first token. But it is not causing a problem either

    As you discovered and stated in your comment, the quotes must be escaped as \". You can use environment variable search and replace to programmatically escape the quotes. Since you must set and expand the variable within a code block, you must use delayed expansion. This is because normal expansion occurs when the line is parsed, and the entire block is parsed at once, so normal expansion will yield the value that existed before the loop was executed!. Delayed expansion occurs when the line is executed.

    @echo off
    setlocal enableDelayedExpansion
    
    ::some additional code to setup KEY and VALUE
    
    for /F %%A in ('REG QUERY "%KEY%" ^| findstr /I /C:"%VALUE%"') do (
      set val=%%A
      REG DELETE "%KEY%" /v !val:"=\"!
    )
    

    I don’t know if it is possible to have ! in the value, but if it is then you must toggle delayed expansion on and off within the loop. Otherwise expansion of %%A will be corrupted when it contains !.

    @echo off
    setlocal disableDelayedExpansion
    
    ::some additional code to setup KEY and VALUE
    
    for /F %%A in ('REG QUERY "%KEY%" ^| findstr /I /C:"%VALUE%"') do (
      set val=%%A
      setlocal enableDelayedExpansion
      REG DELETE "%KEY%" /v !val:"=\"!
      endlocal
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to delete some files using a batch file.. (winxp) my problem
I'm trying to delete some files with unicode characters in them with batch script
I am trying some way to optimize following sql statement: exe_sql DELETE FROM tblEvent_type
I'm trying to write a quick app to modify some registry keys. When I'm
I am trying to delete a registry key, so far I tried that code
I am trying to delete all keys except some in Redis, and I do
I'm trying to delete some cookie which was set by javascript, it works well
I'm trying to batch delete some items in a table. String ids = {
I'm trying to delete a specific line by id from a file in C++
I'm trying to delete certain lines from a file. My file is a .txt

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.