Código:
FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment" /v CurrentVersion') DO set CurVer=%%B
FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\%CurVer%" /v JavaHome') DO set JAVA_HOME=%%B
echo JAVA_HOME: %JAVA_HOME%
SET JAVA=%JAVA_HOME%\bin\javaw.exe
echo JAVA: %JAVA%
Código:
string bat = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "start.bat");
string Xmx = this.textBox1.Text;
string Xmn = this.textBox2.Text;
string NAME = this.textBox3.Text;
Process proc = null;
proc = new Process();
proc.StartInfo.FileName = bat;
proc.StartInfo.Arguments = String.Format("{0} {1} {2}", Xmx, Xmn, NAME);
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(proc.StartInfo.FileName);
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.Start();
string procOutput = proc.StandardOutput.ReadToEnd();
string procError = proc.StandardError.ReadToEnd();
TextWriter outputlog = new StreamWriter(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "instancias\\pruebas\\.minecraft\\log.txt"));
outputlog.Write(procOutput);
outputlog.Close();
TextWriter outputerror = new StreamWriter(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "instancias\\pruebas\\.minecraft\\error.txt"));
outputerror.Write(procError);
outputerror.Close();
Código:
SET BASE=.\
FOR /F "skip=2 tokens=2*" %A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment" /v CurrentVersion') DO set CurVer=%B
FOR /F "skip=2 tokens=2*" %A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\" /v JavaHome') DO set JAVA_HOME=%B
echo JAVA_HOME:
JAVA_HOME:
SET JAVA=\bin\javaw.exe
JAVA: \bin\javaw.exe
El problema es que no se guarda la variable del directorio donde esta java instalado
Muchas gracias y un saludo