Archive: Reg Query Help


Reg Query Help
Hey guys..

i have been trying to avoid posting this for a few days now..
i've gone through the usual cycle of Google, trial & error, reading, searching the forums, more reading.. etc..

GOAL:
Search the registry using a wildcard (*).
I would like the keys found as a result, not just a 1 or 0.

CURRENT:
Im using REG QUERY with a few other AfrowUK macros :) .. but it's painfully slow.. it takes almost 1 minute~! :cry

;=== Search for .vlf*
ExpandEnvStrings $1 %COMSPEC%
nsExec::Exec `"$1" /c REG QUERY "HKEY_LOCAL_MACHINE\Software\Classes" /s | FINDSTR ".vlfteg*" > %TEMP%.\TEMP.TXT`
Push 1 ;line number to read from
Push "$TEMP\TEMP.TXT" ;text file to read
Call ReadFileLine
Pop $0 ;output string (read from file.txt)
StrCmp $0 "" cleanTEMP
${Trim} $2 $0
StrCpy $keytodelete $2
${registry::deleteKey} `$keytodelete` $R0




Im an NSIS noobie, i thought it might just be because of my coding. But after researching.. REG QUERY is known to be dreadfully slow.

Anyone have any suggestions, alternative or tip?
Thank you in advance.

Have you tried using EnumRegKey? http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.5


Search registry with wildcard

Originally posted by MSG
Have you tried using EnumRegKey? http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.5
i saw that on another post that had a similar question..
i looked into it.
but i couldn't figure out how to use wildcards ..

could you show me a quick sample of how i could do that?


=================================


UPDATE:
Nevermind... for some reason.. the manual is confusing to me..
i had no idea what "index" was referring to :)

I got it working now..
It's 1000x faster !

simply incredible..
thank you for your guidance.

F.Y.I.. here's my final coding incase anyone out there needs to do a search with a wildcard.:


;=== search for any reg key that start with .vlf*

StrCpy $0 0
loop:
EnumRegKey $1 HKLM 'Software\Classes' $0
StrCmp $1 "" done
IntOp $0 $0 + 1
StrCpy $9 $1 4
StrCmp $9 '.vlf' 0 loop
${registry::deleteKey} "HKLM\SOFTWARE\Classes\$1" $R0
clearerrors
Goto loop ; loop incase more exists
done:

Addendum
Addendum to code above:

;=== search for .vlf keys
StrCpy $0 0 ; counter
loop:
ClearErrors
EnumRegKey $1 HKLM 'Software\Classes' $0
StrCmp $1 "" done
IntOp $0 $0 + 1 ; add to counter
StrCpy $9 $1 4
StrCmp $9 '.vlf' 0 loop
${registry::deleteKey} "HKLM\SOFTWARE\Classes\$1" $R0
StrCpy $0 0 ; reset counter
Goto loop
done:


* now it loops..
* above code did not loop