Reputation: 635
I want to execute a program within Java with a path that is defined by a custom system variable ("CHROME").
new ProcessBuilder("CHROME").start();
Win7: works fine (points to AppData\Local)
Win Vista: does nothing (points to program files)
What do I need to do, to get it running with Vista?
Upvotes: 0
Views: 1129
Reputation: 136102
If I understood you correctly, CHROME is a system variable which contains the path to an application. If so, you can try as
String path = System.getenv("CHROME");
new ProcessBuilder(path).start();
or
Runtime.getRuntime().exec(path);
Upvotes: 2
Reputation: 20885
In this question is suggested to run the program from cmd.exe
, ie
new ProcessBuilder("cmd.exe", "%CHROME%");
this should work as long as %CHROME%
is in the environmente that the main Java program passes to the subprocess.
Upvotes: 0