beato Posted February 3, 2011 Share Posted February 3, 2011 I'm sure this is easy for most, but I cant seem to get this. I have a reg key I want to delete, but part of the key name could be different for some users (by design). For example RegDelete("HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Autoit Installation Manager 123456-789") Where the number "123456-789" could be different, so I just want to search for "Autoit Installation" and if it finds that, delete that key. So I have tried several methods like: $sKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Autoit Installation Manager *' $i = 1 While 1 $Key = RegEnumVal($sKey, $i) If @error = -1 Then ExitLoop If Not @error And StringRegExp($Key, 'Autoit Installation Manager[ ]?') Then RegDelete($sKey) ContinueLoop EndIf $i += 1 WEnd But again I can't seem to correctly filter (wildcard) directories and reg keys correctly. Any suggestions? Thanks. Link to comment Share on other sites More sharing options...
iamtheky Posted February 3, 2011 Share Posted February 3, 2011 $$i = 1 $root = "'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" while 1 $key = regenumkey ($root, $i) If @Error Then exitloop msgbox (0, '' , $key) If stringinstr($key , "autoit installation") Then regdelete ($root & $key) $i += 1 Else $i += 1 EndIf wend ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
beato Posted February 3, 2011 Author Share Posted February 3, 2011 (edited) $$i = 1 $root = "'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" while 1 $key = regenumkey ($root, $i) If @Error Then exitloop msgbox (0, '' , $key) If stringinstr($key , "autoit installation") Then regdelete ($root & $key) $i += 1 Else $i += 1 EndIf wend Perfect, thank you very much I commented out the msgbox since this portion will run inside a larger piece that is silent. Can you explain how the $i += 1 works/its purpose? Edited February 3, 2011 by beato Link to comment Share on other sites More sharing options...
iamtheky Posted February 3, 2011 Share Posted February 3, 2011 (edited) keeps incrementing the value for the subkey , the messagebox was just for that visual. it means $i = $i + 1 if thats what you were inquiring. Edited February 3, 2011 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
beato Posted February 3, 2011 Author Share Posted February 3, 2011 keeps incrementing the value for the subkey , the messagebox was just for that visual. it means $i = $i + 1 if thats what you were inquiring. Yep, that's what I was referring to. So when it "keeps incrementing the value for the subkey" does that mean it reads (loops) all the keys in the ....Version\Uninstall hive then stops? Thanks again Link to comment Share on other sites More sharing options...
iamtheky Posted February 3, 2011 Share Posted February 3, 2011 (edited) yup it runs them until the @Error, which will hopefully be caused by the loop incrementing to the value 1 greater than the number of subkeys, and not some other cause. Edited February 3, 2011 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now