Sign in to follow this  
Followers 0
autoitNOW

Exit if registry key exist

9 posts in this topic

#1 ·  Posted (edited)

Hi,

Does anyone know the best way to handle a situation where an autoit script looks for a certain registry key and if it finds it than exits?

Any workarounds for If RegKeyExists and RegValueExists type functions?

Thanks in advance

Edited by autoitNOW

An ADVOCATE for AutoIT

Share this post


Link to post
Share on other sites



Yeah....

Last time i checked i couldnt make autoit search the registry, so my amazing workaround is:

run regedit, export to .reg file, rename to .txt open with notepad, scroll through each line, copy to clipboard, maniuplate string to get the keynames.

Much fun it is too. I wrote a little app to wipe out registry entries of virus's that Sophos Antivirus picks up.


Sitting comfortably behind the code.

Share this post


Link to post
Share on other sites

I don't know about the stable version but in the unstable version RegRead has a few nice @error-codes:

Success: Returns the requested registry value value..

Failure: Returns numeric 1 and sets the @error flag:

    1 if unable to open requested key

-1 if unable to open requested value

-2 if value type not supported

So just check if @error is 1 or -1. This should do the trick.

Share this post


Link to post
Share on other sites

Heheh... i still havent dared to download the unstable build...


Sitting comfortably behind the code.

Share this post


Link to post
Share on other sites

Then check your help file. I just redownloaded the stable helpfile and RegRead has the same @error codes... helpfile reading helps.

Share this post


Link to post
Share on other sites

My bad, i read his question wrong... i thought he said an "uncertain" registry key... i.e, he knew the value of the key, but not the keyname... and yes, your correct its in the helpfile, and yes, i read your post wrong too, i thought you were reffering to the unstable RegSearch.


Sitting comfortably behind the code.

Share this post


Link to post
Share on other sites

This was back when I was even newer to AutoIt.

RegRead, RegEnumVal, & RegEnumKey will work.


An ADVOCATE for AutoIT

Share this post


Link to post
Share on other sites

Heheh, i thought it was a little old... ive just been trawling the forum for all unanswered posts.


Sitting comfortably behind the code.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

$mom = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page")

IF $mom = "http://www.microsoft.com" THEN Exit

Edited by Doxie

Were ever i lay my script is my home...

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