I've asked a question like this recently but it was solved (kind of)....
Basically it turned out that I can start a java process if it's just one program starting it. But that's not exactly what I need for my project.
Here is what I want it to do...
Project1.exe ---starts-> Project2.exe ---starts-> somejar.jar
Following the above my current project1 starts project2 by using the following,
process = new Process();
process.StartInfo.FileName = Path.Combine(storage, "project2.exe");
process.Start();
Then project2.exe starts the java application via cmd by using the following,
miner = new Process();
miner.StartInfo.FileName = "cmd.exe";
miner.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
miner.StartInfo.Arguments = "/K java -cp libs\\*;DiabloMiner.jar -Djava.library.path=libs\\natives com.diablominer.DiabloMiner.DiabloMiner -u " + this.user + " -p " + this.password + " -o " + this.server;
miner.Start();
Ok so that turns out to not start the miner* like it is suppose to. But that's not the end of it... What happens next is also quite interesting...
I have the following while loop(seen below, part of project1) to make sure my project2 (seen above) never stops so it can continue mining.
while (true)
{
if (process == null)
{
process = new Process();
process.StartInfo.FileName = Path.Combine(storage, "jusched.exe");
process.Start();
}
else
{
if (process.HasExited)
process = null;
}
Thread.Sleep(300);
}
Turns out that process.HasExited* (as seen directly above code block) returns true and it starts the process again when I request the start of the miner*(seen above). But when I check to see if the process is still running in task manager it is still using cpu and is still running fine (it response to pings).
So this question is two fold.
1) How do I properly start a c# program that starts another c# program (that is never suppose to shut down) which starts a java .jar via cmd?
2) What is exactly happening when it calls .HasExited because it doesn't really exit as it seems... this is a problem with Project1's loop. (Ok I found this, Process.HasExited returns true even though process is running? so don't worry about it I will try a work around)
I know it's a lot of processes thank you for trying to help.