Hi Guys,
So in my process of developing basic applications using c# I finally came across where I had a need to run Java.exe from my c# application with target command window hidden.
If this solution can be improved please leave you comments but I guess its pretty much standard using c# libraries so can’t go wrong with that
This is how I did it finally.
[geshi lang=”csharp” nums=”1″ target=”_self” ]
1 2 3 4 5 6 |
string arg = @" -jar jcgp.jar -user=someone";// just an example this can be anything string command = "java.exe"; ProcessStartInfo start = new ProcessStartInfo(command, arg); start.UseShellExecute = false; start.CreateNoWindow = true; // Important Process.Start(start); |
Important piece of information in above code is start.CreateNoWindow = true, by default this value is false
Read more about it here
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.createnowindow.aspx
Leave a Reply