?
Solved

Reg query problem

Posted on 2010-03-25
5
Medium Priority
?
540 Views
Last Modified: 2012-05-09
Hi guys,

reg query "hklm\software\microsoft\windows nt\currentversion\profilelist" /s | find /i "S-1-5-21">> parent.txt

This gives me:

=========================== parent.txt
HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\profilelist\S-1-5-21-1187487854-1727753276-2704374040-103101.bak
HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\profilelist\S-1-5-21-1187487854-1727753276-2704374040-4229

But, when I then do:

for /f %%c in (parent.txt) do @echo %%c

I get:

HKEY_LOCAL_MACHINE\software\microsoft\windows
HKEY_LOCAL_MACHINE\software\microsoft\windows

instead of:

HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\profilelist\S-1-5-21-1187487854-1727753276-2704374040-103101.bak
HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\profilelist\S-1-5-21-1187487854-1727753276-2704374040-4229

Any help greatly appreciated.
0
Comment
Question by:Simon336697
5 Comments
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 800 total points
ID: 28638036
Try this:

for /f "delims=" %%c in (parent.txt) do @echo %%c

Open in new window

0
 
LVL 1

Author Comment

by:Simon336697
ID: 28639100
Hi farhankazii,

That works thanks so much, but im not sure why it works.
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 28640658
If you specify delims=xxx in FOR statement, it will replace the default delimiter which is set to space and tab. This is the reason you were getting everything before the first space (in Windows NT)

HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\profilelist\.....
                                                                                        ^
0
 
LVL 21

Assisted Solution

by:AmazingTech
AmazingTech earned 600 total points
ID: 28688988
You can also put in "tokens=*"
0
 
LVL 60

Assisted Solution

by:Bill Prew
Bill Prew earned 600 total points
ID: 28714115
Here are a couple of references that may help you master the FOR /F command a bit.

http://ss64.com/nt/for_cmd.html
http://www.robvanderwoude.com/ntfor.php

~bp
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…

593 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