Skip to content

Commit

Permalink
Check environment for the Path if run by first-time wizard
Browse files Browse the repository at this point in the history
Signed-off-by: Arne Babenhauserheide <[email protected]>
  • Loading branch information
naejadu authored and ArneBab committed Jun 6, 2022
1 parent 5b1f6ed commit 278ba8e
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions MachineConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void CheckConfig(string pathConfig)
{
string line = lines[i];

/*
/* ================================
* CHECK AND RUN JAVA COMMAND
*
*/
Expand Down Expand Up @@ -62,7 +62,7 @@ public static void CheckConfig(string pathConfig)
}


/*
/* ================================
* ENABLE OR DISABLE LAUNCH PARAMETERS FOR JAVA8 OR JAVA 9+
*
*/
Expand Down Expand Up @@ -98,6 +98,36 @@ public static void CheckConfig(string pathConfig)

private static void GetJVMinfo(string pathJVM)
{

/* ================================
* Only run if the installer started tray.exe with "-welcome" arg.
* If OS did not have Java installed, the Freenet installer installed a JVM.
* This JVM's java.exe can be found in PATH.
* Problem: Installer starts tray.exe with old environment variables,
* meaning PATH does not contain Java.exe at this point.
* This results in "JVM not found" error.
* Solution: Read environment variables again.
*
*/
foreach (var arg in Environment.GetCommandLineArgs())
{
if( arg.Equals("-welcome") )
{
string machineEnv = System.Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
string currentEnv = System.Environment.GetEnvironmentVariable("Path");
if( !machineEnv.Equals(currentEnv) )
{
System.Environment.SetEnvironmentVariable("Path", machineEnv);
}
break;
}
}


/* ================================
* RUN JAVA AND GET JVM INFO
*
*/
using (System.Diagnostics.Process pProcess = new System.Diagnostics.Process())
{
pProcess.StartInfo.FileName = pathJVM;
Expand Down

0 comments on commit 278ba8e

Please sign in to comment.