blindwig Posted April 2, 2006 Share Posted April 2, 2006 (edited) Something like this maybe? Dim $s_Root = 'HKEY_LOCAL_MACHINE\SOFTWARE\MyProg' Dim $i_Key = 1, $s_Key = RegEnumKey($s_Root, $i_Key) While not @Error $s_Val = RegEnumVal($s_Root & '\' & $s_Key, 1) If @error Then RegDelete($s_Root & '\' & $s_Key) $i_Key += 1 $s_Key = RegEnumKey($s_Root, $i_Key) WEnd Basically you're wanting to go through all the keys in a particular key and remove any that do not have values. Is that correct? Edited April 2, 2006 by blindwig My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
nfwu Posted April 3, 2006 Share Posted April 3, 2006 (edited) So, let's recap on what you would like to do. If app2 is empty or not there remove app1 Else remove myprog EndIf And, you are having problems on detecting on whether a key is empty. (If only got (default), then considered empty, right?) Solution: If _IsRegKeyEmpty ("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2") = 1 Then RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") Else RegDelete("HKEY_CURRENT_USER\Software\MyProg") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg") EndIf Func _IsRegKeyEmpty($regkey) Dim $i_Key = 1, $s_Key = RegEnumKey($regkey, $i_Key) While not @Error If Not ($s_Key = "" Or $s_Key = "(default)") Then Return 0;;not empty $i_Key += 1 $s_Key = RegEnumKey($regkey, $i_Key) WEnd Return 1;;empty EndFunc Not tested... #) EDIT: more typos Edited April 3, 2006 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
RvdH Posted April 3, 2006 Author Share Posted April 3, 2006 thanks nfwu, got it working using your approuch the actual purpose was to delete the MyProg key if nothing else was in it...here is the final script: Func _IsRegKeyEmpty($regkey) Dim $i_Key = 1, $s_Key = RegEnumKey($regkey, $i_Key) While not @Error If Not ($s_Key = "" Or $s_Key = "(default)") Then Return 0;;not empty $i_Key += 1 $s_Key = RegEnumKey($regkey, $i_Key) WEnd Return 1;;empty EndFunc ; Clean App1 Settings RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") ; Clean MyProg Settings if empty if not _IsRegKeyEmpty("HKEY_CURRENT_USER\Software\MyProg") = 0 then ; other appz do not exist, so here it removes the whole key RegDelete("HKEY_CURRENT_USER\Software\MyProg") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg") endif 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