RvdH Posted April 1, 2006 Share Posted April 1, 2006 ok, let me try to explain, got several applications that are installed and have writen a few registry entries, now i wan't to remove 1 app from registry but if the other app is present it may not remove registry entries that are shared, like: if RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2") 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 i've tried several things, if RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2")<>"" then if RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2")="" then if RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2","<variable>")="" then But unfortunatly it doesn't like my script... How can i check if a registry value exists and if it does exist the <variable> is different every time so, if possible it should ignore that RvdH Link to comment Share on other sites More sharing options...
blindwig Posted April 1, 2006 Share Posted April 1, 2006 Look at the file file for the RedRead() function It does return error code for key and value not found 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...
RvdH Posted April 2, 2006 Author Share Posted April 2, 2006 (edited) i do not quite get it i think... $app2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App2") If @error Then $app2 = 0 Else $app2 = 1 EndIf If $app2 <> 0 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 Seems like it should work, but as i hardly have any experience with auto-it it could be a simple syntax error, Can anyone give a example on how it should be done? thx, RvdH Edited April 2, 2006 by RvdH Link to comment Share on other sites More sharing options...
nfwu Posted April 2, 2006 Share Posted April 2, 2006 Failure: Returns "" and sets the @error flag:If RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App2") = "" Then RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") EndIf RegDelete("HKEY_CURRENT_USER\Software\MyProg") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg") As i do not have your registry i cannot replicate the problem. Can you take a screenshot of your registry in "regedit"? #) 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 2, 2006 Author Share Posted April 2, 2006 Nothing to make a screenshot from... it just this code i am experimenting with...If RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App2") = "" Then RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1")EndIfRegDelete("HKEY_CURRENT_USER\Software\MyProg")RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg")In you method it deletes both, eg; "HKEY_CURRENT_USER\Software\MyProg\App1" & "HKEY_LOCAL_MACHINE\SOFTWARE\MyProg"The required event should be if another app exists in the same registy tree it would only remove the registry entry for that app, and if no other apps are in that registry tree it removes all Link to comment Share on other sites More sharing options...
nfwu Posted April 2, 2006 Share Posted April 2, 2006 If RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App2") = "" 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 This works? #) 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 2, 2006 Author Share Posted April 2, 2006 (edited) kinda, think i had the exact same code somewhere in my attempts, but think i know now why it isn't working as i would it should,if the registry, HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App2" doesn't have any values besides the (default) value and other settings are stored in additional subkeys (like, HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2", "settings") the presense of the (default) value makes the above function think it isn't empty, but for this function to work properly it should... (am i right?)To access the (Default) value use "" (a blank string) for the valuename. Edited April 2, 2006 by RvdH Link to comment Share on other sites More sharing options...
nfwu Posted April 2, 2006 Share Posted April 2, 2006 Yar, correct! #) 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 2, 2006 Author Share Posted April 2, 2006 Anything i can do to prevent that?can we use wildcards as regsitry keys, like:If RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2\*", "") = "" ThenRegDelete("HKEY_CURRENT_USER\Software\MyProg\App1")RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") Link to comment Share on other sites More sharing options...
RvdH Posted April 2, 2006 Author Share Posted April 2, 2006 Another thingy, can't RegEnumKey be used to check if "app2" is installed? $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App2") if $var @error then RegDelete("HKEY_CURRENT_USER\Software\MyProg") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg") else RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") end if Link to comment Share on other sites More sharing options...
RvdH Posted April 2, 2006 Author Share Posted April 2, 2006 Ah come on, there has to be a way once again i will try to explain what i am trying to do...the idea is to remove a registry key, BUT only if it isn't used by other programs, like:HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") ; this is the one we are removingHKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2") HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App3") ; here is should check if other programs are presentif RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2") = "" or RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App3") = "" then; other appz exist, so here it removes registry entries for only app1 RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") else; other appz do not exist, so here it removes the whole key RegDelete("HKEY_CURRENT_USER\Software\MyProg") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg")endifObviously, the code above isn't working... whatever i try always something remains in the registry Man, never could have thought it would be this hard to accomplish such a easy task Anyone can give me more insight?RvdH Link to comment Share on other sites More sharing options...
Developers Jos Posted April 2, 2006 Developers Share Posted April 2, 2006 (edited) Ah come on, there has to be a way Untested but something like this ? ; here is should check if other programs are present RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2") $Check1 = @error RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App3") $Check2 = @error ; here is should check if other programs are present if $Check1 <> 1 and $Check2 <> 1 then ; other appz exist, so here it removes registry entries for only app1 RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") else ; 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 EDIT.. Changed test if you want that both are present .. Edited April 2, 2006 by JdeB SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
blindwig Posted April 2, 2006 Share Posted April 2, 2006 You cuold use RegEnumVal() to check if there are any values in the key 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...
RvdH Posted April 2, 2006 Author Share Posted April 2, 2006 (edited) "Error: Incorrect number of parameters in function call." on the two lines below, RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2") RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App3") but if i change it in its proper format, eg; RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App2") RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App3") ii always end up with a empty registry key and it's not being removed (maybe the "default" value we discussed above) like: HKEY_LOCAL_MACHINE\SOFTWARE\MyProg Edited April 2, 2006 by RvdH Link to comment Share on other sites More sharing options...
RvdH Posted April 2, 2006 Author Share Posted April 2, 2006 You cuold use RegEnumVal() to check if there are any values in the keyhuh? can you give me a example, the example given in the help doesn't help much in this case Link to comment Share on other sites More sharing options...
Developers Jos Posted April 2, 2006 Developers Share Posted April 2, 2006 (edited) "Error: Incorrect number of parameters in function call." on the two lines below, RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2") RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App3") but if i change it in its proper format, eg; RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App2") RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "App3") ii always end up with a empty registry key and it's not being removed (maybe the "default" value we discussed above) like: HKEY_LOCAL_MACHINE\SOFTWARE\MyProg Yea should have run a au3check on that... If the APP1 is part of the KEY then it cannot be put in the Keywork parameter... You should then use : ; here is should check if other programs are present RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2","") $Check1 = @error RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App3","") $Check2 = @error ; here is should check if other programs are present if $Check1 = 1 or $Check2 = 1 then ; other appz exist, so here it removes registry entries for only app1 RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") else ; 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 Edited April 2, 2006 by JdeB SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
RvdH Posted April 2, 2006 Author Share Posted April 2, 2006 ok, that still didn't work, i ended up with everything being deleted, but finally i think i have seen the light, eg: ; here is should check if other programs are present $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", 1) $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", 2) ; here is should check if other programs are present if $var = "App2" or $var = "App3" then ; other appz do exist, so here it removes the app1 key RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") else ; 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...
RvdH Posted April 2, 2006 Author Share Posted April 2, 2006 (edited) but that brings me to the next issue App1 registry entries are still present at that point, thus: $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", 1) --> App1 $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", 2) --> App2 And what if in the future more app(nr) get added to the same key? Can i somehow loop trough the $var and check if "App2" & "App3" are in it? BTW, Thanks to you all for all your help on this this far! RvdH Edited April 2, 2006 by RvdH Link to comment Share on other sites More sharing options...
Developers Jos Posted April 2, 2006 Developers Share Posted April 2, 2006 (edited) I am still not sure about your exact logic. So if either app1 OR app2 registry key exists, your want to delete the app1 keys Else remove Myprog ? Like this ? ; here is should check if other programs are present RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App2","") $Check1 = @error RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App3","") $Check2 = @error ; here is should check if other programs are present if $Check1 = 0 or $Check2 = 0 then ; other appz exist, so here it removes registry entries for only app1 RegDelete("HKEY_CURRENT_USER\Software\MyProg\App1") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg\App1") else ; 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 Edited April 2, 2006 by JdeB SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
RvdH Posted April 2, 2006 Author Share Posted April 2, 2006 (edited) your method just doesn't work...i do not know why, with yours every registry entry gets deleted, it has to be something with (DEFAULT) value To access the (Default) value use "" (a blank string) for the valuename.the "RegEnumKey" method works but now i have to find a way to loop through al subkeys in the particular registry key Edited April 2, 2006 by RvdH 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