Sign in to follow this  
Followers 0
rnj

StringRegExp

3 posts in this topic

#include<string.au3>

I am trying to extract the keys starting with the letter KB(for MS KB)...This is ending in a crazy loop..Suggestions Please....

For $i_loop= 1 to 100

$MS_KB_Reg_Value = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", $i_loop)

SplashTextOn("Value1",$MS_KB_Reg_Value,700,75)

Sleep(200)

SplashOff()

If @error <> 0 then ExitLoop

$MS_KB_Reg_Value_Temp = StringRegExp($MS_KB_Reg_Value,"\<KB")

For $j_loop = 1 To 72

$MS_KB_Reg_Value1 = _StringInsert("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", $MS_KB_Reg_Value_Temp,$j_loop)

SplashTextOn("Value3 ",$MS_KB_Reg_Value1,700,75)

Sleep(200)

SplashOff()

Next

Next

:)


[font="Franklin Gothic Medium"]RnJ[/font][font="Franklin Gothic Medium"]Script: AutoIT v3.1.1.124 (beta)[/font][font="Franklin Gothic Medium"]OS: Windows XP/2000[/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Perhaps this is something like you need? or something close to your intentions.

$Key = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
For $i_loop = 1 To 1000
    $MS_KB_Reg_Value = RegEnumKey($Key, $i_loop)
    If @error Then ExitLoop
    If StringRegExp($MS_KB_Reg_Value,"\<KB\A+") Then
        SplashTextOn("Value3 ",$Key & $MS_KB_Reg_Value,700,75)
        Sleep(200)
        SplashOff()
    EndIf
Next

I removed _StingInsert(), as I was unsure of the usage wanted with it.

I see no reason for 2 loops.

StringRegExp() returns 0 or 1, so just needed to boolean the success of finding a KB***** key.

:)

Edit:

Do read the @error macro immediately after a function call.

Edited by MHz

Share this post


Link to post
Share on other sites

Ohhh...That was indeed a simple way....Cheers Mhz..:)


[font="Franklin Gothic Medium"]RnJ[/font][font="Franklin Gothic Medium"]Script: AutoIT v3.1.1.124 (beta)[/font][font="Franklin Gothic Medium"]OS: Windows XP/2000[/font]

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  
Followers 0