I have a simple code that prints registry values in a specific key. The problem is that I get an active directory printed with each iteration of the loop below.
For recording, I use a different key with two DWORD values: NAME and Test
@Echo Off
set SpecialUserRegDir=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
REG QUERY "%SpecialUserRegDir%" /s | for /F %%f in ('findstr "REG_DWORD"') do (
@echo %%f
[increment will be here]
)
Output
C:\User\[username]\Desktop\RegTest>()
NAME
C:\User\[username]\Desktop\RegTest>()
Test
I know that this problem disappears if I replace the do block with the signle command, but there will be different code in the block do, so I cannot replace it with a singular command.
With that in mind, is there a way to write a REG QUERY command (and a combination after that) without printing C:\User\[username]\Desktop\RegTest>()?
source
share