I am creating a .exe
to run a .jar, it works, the only problem is that it shows a popup( CMD
) for a few milliseconds, is there any way to make this not happen?
Here my code to run the .bat
:
using System;
namespace Launch
{
class MainClass
{
public static void Main(string[] args)
{
System.Diagnostics.Process.Start("start.bat");
}
}
}
this is my .bat
:
@echo off
cd "C:\Program Files (x86)\START"
"C:\Program Files (x86)\START\jre8\bin\javaw.exe" -jar -XX:+UseConcMarkSweepGC -Xmx1024M -Xms1024M START.jar
Another way I tried was to do everything from C#
(but got the same result):
using System.Diagnostics;
namespace Launch
{
class MainClass
{
public static void Main(string[] args)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.Arguments = "-jar -XX:+UseConcMarkSweepGC -Xmx1024M -Xms1024M START.jar";
psi.CreateNoWindow = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.FileName = "jre8\\bin\\javaw.exe";
Process.Start(psi);
}
}
}
You need to set the use of a shell(
UseShellExecute
) to false, here is your code along with the missing line:you may:
either
either