Sign in to follow this  
Followers 0
teeboi

IF Registry Exist Then Delete

5 posts in this topic

I am trying to write an autoit script which will check for a registry value "SunJavaUpdateSched" & if its exist then delete can someone please help.

"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "SunJavaUpdateSched"

Share this post


Link to post
Share on other sites



If RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" , "SunJavaUpdateSched" ) Then RegDelete ( "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" , "SunJavaUpdateSched" )

I got this working :)

Share this post


Link to post
Share on other sites

You don't have to check to see it it exists or not. If there is a problem deleting (for whatever reason) you can check the return value of RegDelete()

If RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "SunJavaUpdateSched") = 1 Then
    MsgBox(0, "Result", "The Registry key was deleted")
Else
    MsgBox(0, "Error", "Deleting the key returned error code " & @Error)
EndIf

I don't know what you were trying to do with the /v but it's not required.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks MVP for your quick response. I agree with you that's also another way of doing it but i didn't wanna to show any msg box or user intervention & that's why i took the regread & regdelete route. I am still new @ this. It's actually my second script that i wrote hopefully as i go along i'll get better @ it. once again thanks for your feedback

Edited by teeboi

Share this post


Link to post
Share on other sites

The message box was in there for demo purposes only. You can do anything you want in that If statement or not bother checking it at all. It won't make any difference to the outcome. Either the key exists and get deleted or it doesn't exist and the script continues.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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