Sign in to follow this  
Followers 0
rsh

Setting Registry Settings recursively

12 posts in this topic

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



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


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

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

My bad...it is working...thank you!!!!!

Share this post


Link to post
Share on other sites

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")

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

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

and this performs the write?

RegWrite("HKLMSOFTWAREJavaSoftJava Runtime Environment" & $var, "JAVAUPDATE", "REG_SZ", "0")

Share this post


Link to post
Share on other sites

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

Perhaps this line?

$var = RegEnumKey("HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment" & $i, $i)


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

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

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")

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

PERFECT! Works wonderfully. You have been a huge help!!!!

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