Jump to content

Recommended Posts

Posted

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

Posted

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!

Posted

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

Posted

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!

Posted

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)

Posted

and this performs the write?

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

Posted

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.

Posted

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

Posted

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!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...