Is it possible to override the value of an arbitrary Windows registry key for a specific application lifecycle?
My hope is that a temporary registry value can be set with the command line, so that I can combine it with the following batch-y temporary environment variable change (to point to the 1.7 JDK).
C:\Windows\System32\cmd.exe /c "SET JAVA_HOME=C:\Program Files\Java\jdk1.7.0_75&& START /D ^"C:\Path\To\^" SpecialSnowflake.exe"
Situation Specific Details:
I'm using a program that requires a JDK (so I've kind of already lost). The quality of the programming is dubious. I have speculated over the relevant events in Process Monitor and pieced together a probable timeline. These details don't seem relevant to the task of temporarily overriding a registry value, but here they are, just in case:
When the program tries to pick and start the correct version of java.exe, it checks the registry path
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\java.exe. Presumably, the program expects this bizarre-looking key to point to the most current version of Java (why not use the Path and/or JAVA_HOME vars?), however, this strange key does not exist on any of my PCs. Since the key is not found, the program uses a likely hardcoded default path for Java, which turns out to be %windir%\SysWOW64\java.exe. That particular java.exe has not been touched by any of the 1.8 JRE/JDK installers, and thus remains outdated at 1.7 on my PCs. This 1.7 java.exe is launched. It checks the key
HKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\CurrentVersion, reads 1.8, and terminates itself. The troublesome program in question notices this, reports that the key is 1.8, but should be 1.7, and helpfully provides the wrong registry path to a key that was never checked:
'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'(oddly placed
'chars not added by me).