This took me a couple of frustrating days to get working, and I wasn’t able to find a direct example in the forums to accomplish this, so I thought I would share!
We needed to add Java’s bin directory to the Windows ‘Path’ Environment Variable. I tried several approaches, including creating a .reg file, creating a .bat file, and simply using the command regset - none of them worked 100%. I finally gave up on the more “elegant” approaches, and just used the command line command to edit the registry. The action command that I ended up with looks something like this:
/v - Value that you want to add
/r - data type that you’re adding
/d - data that you are adding to the value
/f - forces the key to be added even if it already exists
I was a combination of the existing Path variable and relevance to build the data that I needed to add. If anyone has any other experience with something similar, please share.
Do you have the code you tried using regset? I’m guessing that there was a syntax error of some sort, because there is no reason that this would work and regset and/or regset64 would not.
Also, I believe there is a way to add to the PATH using a command instead of modifying the registry directly.
Thanks, jgstew. I had also looked at the setx command to accomplish this, but I had initially thought using regset would be simpler as I have had more experience with it versus setx (which I have no experience with ).
The original method I tried used the regset action command. Here’s the code:
regset “[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]” “Path”="{program files folder as string & “\Java\jre7\bin;” & value “Path” of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry as string}"
The command evaluates with no issues, but does not update the registry value at all. On 64-bit machine using regset64, I see the same result of no modifications to the registry.
program files folder as string & "\Java\jre7\bin;" & value "Path" of key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" of registry as string
Try the following ActionScript:
dos setx /M PATH "%PATH%;{program files folder as string & "\Java\jre7\bin"}"
Yes - the relevance does evaluate correctly in the fixlet debugger, and when incorporated in the action command, it does evaluate to the correct data value that I want to add.
To manipulate the PATH variable, I personally prefer PATHMAN.EXE (which was in, I believe, the 2003 Resource Kit tools). PATHMAN can distinguish between per-machine and per-user PATH variables, and avoids adding a duplicate entry if the specified folder is already in the path.
I came across this while trying to figure out my similar problem. I need to recreate three system variables, after deleting them for upgrading JRE. I need to place them in HKLM\SYSTEM\CurrentControlSet\Control\Session\Manager\Environment\
One of the three variables is a simple string that’s easy to add using regset…but two have lengthy variables…here’s one of them. I tried regset and setx /m _JAVA_OPTIONS and everything after that…I assume I have incorrect syntax. Anyone know what to do?
Hi, thanks for the reply. Pathman - I will do some reading.
Here’s the regset I attempted:
regset “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment_JAVA_OPTIONS” “StringValue”=""-Xrunjvmhook -Xbootclasspath/a:“C:\Program Files (x86)\HP\Sprinter\bin\java_shared\classes”;“C:\Program Files (x86)\HP\Sprinter\\bin\java_shared\classes\jasmine.jar”"
With this failure, I thought maybe I need to just some of the variable…that everything after the semicolon needed to be appended to the variable in a second action, so I deleted everything after the semicolon, but that didn’t work either.