Check to see if registry key exist and if so delete the key

I am looking to see if this registry key exist SunJavaUpdateSched and if so delete the key. I have tried the following but is not deleting the key.

if {exist key "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run " whose ( value “SunJavaUpdateSched” of it =“C:\Program Files (x86)\Common Files\Java\Java Update\jusched.exe”) of registry}

regdelete64 “[HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run]” “SunJavaUpdateSched”

else

endif

I think part of the reason is you are using the BigFix shortcut HKLM in the part that goes to the Windows code so have you tried on the regdelete part to put HKEY_LOCAL_MACHINE ?

I tried that and still does not delete the key. Not sure what else the issue can be.

Can you find the key you are trying to delete in registry editor and take a screenshot of the entire registry editor so we can see the path on the bottom of the window, the name of the key, etc?

Bill

Actually I think you have a few things bad here. The detection is looking at the registry as 32 bit but with 64 bit paths as well

Try this

if {exist key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" whose ( value "SunJavaUpdateSched" of it = "C:\Program Files (x86)\Common Files\Java\Java Update\jusched.exe") of registry} 

regdelete "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]" "SunJavaUpdateSched"
endif

This is all because you only need to look at the system as a 32 bit registry and not have the WOW64 elements in it.
Be aware you may have to do more manipulations of the if part as its possible the value has %PROGRAMFILES% as the string element

1 Like

Here is the screenshoot:

I have tried that relevance and it still does not work. What else am I doing wrong?

Lets get the relevance working and then we can work on the actionscript.

What do these queries return if you do them in Fixlet Debugger on the machine?

Q: exist key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" of x32 registry


Q: exist value "SunJavaUpdateSched" of key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" of x32 registry


Q: value "SunJavaUpdateSched" of key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" of x32 registry

The first two equal true and the last one equals “C:\Program Files (x86)\Common Files\Java\Java Update\jusched.exe”

And can you run this?

Q: exist value "SunJavaUpdateSched" whose (it = "C:\Program Files (x86)\Common Files\Java\Java Update\jusched.exe") of key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" of x32 registry

It comes back as false.

Oh – the value is wrapped in quotes in the registry. Got it.

Q:exist value "SunJavaUpdateSched" whose (it = "%22C:\Program Files (x86)\Common Files\Java\Java Update\jusched.exe%22") of key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" of x32 registry

And then the actionscript Alan provided should work:

regdelete "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]" "SunJavaUpdateSched"

The escape character worked … Thank you…