The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

environment variables

hi all,
  i have to make entries/update in the environment variables and that too in java (non negotiable lang).

so i am executing  a reg file which has the necessary parameters.

and this works fine except for the fact that for this variables to take effect i have to restart my machine.

is there any other way,so that i don't have to restart my machine?

thanks a ton
Send private email
Wednesday, August 10, 2005
The SetEnvironmentVariable Win32 function lets you change the environment variables of the currently running application.

If you can get to it from Java that should work.
Jussi Jumppanen
Wednesday, August 10, 2005
Alternatively, you could call out to the operating system. Ant does this to read the environment variable from the OS. Basically it executes the SET command, captures the output and parses it. You could do the same, executing a command like

 call SET MYVAR=SomeValue

Now that will just set it for the current command prompt, it won't go to control panel for you and set it so that it will stick. But even if you can't do that in Java, a tiny script program might do it for you, and you could call that from Java.
Friday, August 12, 2005
After changing the registry entries, you need to broadcast a WM_SETTINGCHANGE message.  MSDN documentation link is below, but I have no idea how to do this in Java.
Tim Evans Send private email
Monday, August 15, 2005

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz