rsh 0 Posted January 11, 2012 I have a situation where I need to modify the registry settings following a Java Install.Basically I need to do the followint (this code works):RegWrite("HKLM\SOFTWARE\JavaSoft\Java Plug-in\10.2.0", "UseJava2IExplorer", "REG_DWORD", "1")The problem is that there are multiple versions and they can be different on the users machine...so I need to look through each of the versions and look for the key, and if it exists update it.RegWrite("HKLM\SOFTWARE\JavaSoft\Java Plug-in\10.2.0", "UseJava2IExplorer", "REG_DWORD", "1")RegWrite("HKLM\SOFTWARE\JavaSoft\Java Plug-in\10.2.1", "UseJava2IExplorer", "REG_DWORD", "1")So how do I loop through each version and if the key exists update it?Thank you very much for your time.Ron Share this post Link to post Share on other sites
kaotkbliss 146 Posted January 11, 2012 Mostly taken from the help file For $i= 1 to 10 $var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Plug-in", $i) If @error <> 0 then ExitLoop MsgBox(4096, "SubKey #" & $i & " under HKLMSoftware: ", $var) Next You can then use $var for your key search HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Plug-in$var 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
rsh 0 Posted January 11, 2012 Thank you for the quick reply. I modified my code to this: For $i= 1 to 10 $var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Plug-in", $i) If @error <> 0 then ExitLoop RegWrite("HKLMSOFTWAREJavaSoftJava Plug-in" & $var, "UseJava2IExplorer", "REG_DWORD", "0") Next Unfortunately it is not updating the value. What am I missing/ Thanks! Ron Share this post Link to post Share on other sites
rsh 0 Posted January 11, 2012 My bad...it is working...thank you!!!!! Share this post Link to post Share on other sites
kaotkbliss 146 Posted January 11, 2012 Maybe move the regwrite to just after the loop? For $i= 1 to 10 $var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Plug-in", $i) If @error <> 0 then ExitLoop Next RegWrite("HKLMSOFTWAREJavaSoftJava Plug-in" & $var, "UseJava2IExplorer", "REG_DWORD", "0") 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
rsh 0 Posted January 11, 2012 Okay one more issue...I have another instance where the version is followed by "MSI" how do I do that? Like this?: $var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment" & $i & "MSI", $i) Share this post Link to post Share on other sites
rsh 0 Posted January 11, 2012 and this performs the write? RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var, "JAVAUPDATE", "REG_SZ", "0") Share this post Link to post Share on other sites
rsh 0 Posted January 11, 2012 So I modified the code you gave me to: For $i= 1 to 20 $var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment" & $i, $i) If @error <> 0 then ExitLoop RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", "AUTOUPDATECHECK", "REG_SZ", "0") RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", "IEXPLORER", "REG_SZ", "0") RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", "JAVAUPDATE", "REG_SZ", "0") Next Unfortunately this does not work...Im sure my syntax is wrong. Share this post Link to post Share on other sites
kaotkbliss 146 Posted January 11, 2012 Perhaps this line? $var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment" & $i, $i) 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
rsh 0 Posted January 11, 2012 Yeah I agree... I tried this code as well with no success: For $i= 1 to 20 $var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment" & $i & "MSI", $i) If @error <> 0 then ExitLoop MsgBox(4096, "SubKey #" & $i & " under HKLMSoftware: ", $var) RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", "AUTOUPDATECHECK", "REG_SZ", "0") RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", "IEXPLORER", "REG_SZ", "0") RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", "JAVAUPDATE", "REG_SZ", "0") Next Share this post Link to post Share on other sites
kaotkbliss 146 Posted January 11, 2012 Something like this? For $i= 1 to 20 $var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment",$i) If $var <> "" then For $i2= 1 to 20 $var2 = RegEnumVal("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", $i2) If $var2 <> "" then ExitLoop(2) EndIf Next EndIf Next MsgBox(4096, "SubKey #" & $i & " under HKLMSoftware: ", $var) MsgBox(4096, "SubKey #" & $i & " under HKLMSoftware: ", $var2) RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", "AUTOUPDATECHECK", "REG_SZ", "0") RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", "IEXPLORER", "REG_SZ", "0") RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var & "MSI", "JAVAUPDATE", "REG_SZ", "0") 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
rsh 0 Posted January 11, 2012 PERFECT! Works wonderfully. You have been a huge help!!!! Share this post Link to post Share on other sites