.Bat that extracts an specific regsitry key (SID) to a .txt or .reg file

5 pts.
Tags:
Batch files
Registry
SID
Hello, how can i extract only the exact SID key from the registry with a .bat like this: ExtractSID.bat: REG QUERY HKU |Findstr /R "DEFAULT S-1-5-[0-9]*-[0-9-]*$" >> SID.txt With result on file SID.txt: HKEY_USERS.DEFAULT HKEY_USERSS-1-5-21-57989841-484763869-1957994488-1003 What i need on SID.txt: S-1-5-21-57989841-484763869-1957994488-1003

Answer Wiki

Thanks. We'll let you know when a new response is added.

You may want to look into using the FOR command to process the SID.txt file line by line looking for the line which doesn’t end in .DEFAULT.

Something like (this isn’t tested):
<pre>FOR /F “delims=\ skip=1 tokens1,2″ %%a in (SID.txt) do echo %%b > SID.txt</pre>

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomWahl
    Add a line that filters using the FIND command to exclude lines with a specific string in them. type SID.txt | find /v /i "default" >ONLY_SID.txt The /v tells FIND to ignore the string "default" and the /i makes it case insensitive.
    85 pointsBadges:
    report
  • TQuinnelly
    Just to add to Mrdenny's answer...check out this site for some great command line reference.
    45 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following