Jump to content
Sign in to follow this  
FuryCell

Help my udf to count vals in a reg key fails

Recommended Posts

FuryCell

I am trying to write a program to remove netbus 1.70

it is supposed to compare every program in the key HKEY_Local_Machine\Software\Windows\Currentversion\Run to to the netbus server program using

the dos command FC. and then delete the key that is is the one for netbus and then delete the program as found in the registry.it then will delete other keys assiated with netbus.I tried this but it does not work as it always returns 20

Here is the script i wrote to test my function

$EntryCount=RegCountEntries ("HKEY_CURRENT_USER\Software\TestKey")
MsgBox (4096,"",$EntryCount)
Func RegCountEntries ($RCE_Key)
    Local $RCE_Key
    Local $RCE_N
    Local $RCE_CheckForEntry
    Local $RCE_EntryCount

    For $RCE_N= 1 to 20
        $RCE_CheckForEntry=RegEnumVal ($RCE_Key, $RCE_N)
        If $RCE_CheckForEntry=-1 then 
            $RCE_EntryCount=$RCE_N - 1
            ExitLoop
        EndIf
        If $RCE_N=20 then
            $RCE_EntryCount=20
            ExitLoop
        EndIf


    Next
    Return $RCE_EntryCount
EndFunc

The Key "HKEY_CURRENT_USER\Software\TestKey"

contained 4 blank entries called 1,2,3,and 4

any help would be greatly appreciated


HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites
FuryCell

Sorry for posting twice. i hit the button to post the topic but realized i made a mistake and hit back and it put too posts

any body know how i can delete one?


HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites
SlimShady

This one works for me:

$EntryCount=RegCountEntries ("HKEY_CURRENT_USER\Software\TestKey")
MsgBox (4096,"",$EntryCount)
Func RegCountEntries ($RCE_Key)
    Local $RCE_Key
    Local $RCE_N = 0
    Local $RCE_CheckForEntry
    Local $RCE_EntryCount

    While 1
        $RCE_N = $RCE_N + 1
        $RCE_CheckForEntry=RegEnumVal ($RCE_Key, $RCE_N)
        If @error then 
            $RCE_EntryCount=$RCE_N - 1
            ExitLoop
        EndIf
    WEnd
    Return $RCE_EntryCount
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.