0

I am using C# to run another .exe applicaiton.

however I want to run the .exe in background I tried Start info hide bu.t it didn't help

How can I do that?

currently this is the code I am using

_p = new System.Diagnostics.Process();
_startInfro = new System.Diagnostics.ProcessStartInfo();
_startInfro.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;                       
_startInfro.FileName = tmp[0];
_startInfro.Arguments = deleteRangeCommand;
_p.StartInfo = _startInfro;
_p.Start();
Barak Rosenfeld
  • 307
  • 1
  • 6
  • 14
  • You may find an answer to your question here: [.NET - WindowStyle = hidden vs. CreateNoWindow = true?](http://stackoverflow.com/questions/5094003/net-windowstyle-hidden-vs-createnowindow-true) - if it's not your exe and you cannot implement extra parameters for hiding the process then it probably cannot be done much or you need to use some of the Windows APIs to achieve this. Anaways, you can read there when these parameters are respected by which application. – t3chb0t Dec 28 '14 at 11:03

1 Answers1

1

Since I you don't provide information about which .exe you want to start I can't be sure about this answer. But the CreateNoWindow property looks like what you need.

You must also set the UseShellExecute property to false as is pointed out in the documentation. Otherwise the value of CreateNoWindow is ignored.

Chrono
  • 1,433
  • 1
  • 16
  • 33
  • HI, thank you for your answer however I changed my code and it still opened the didn't help :( – Barak Rosenfeld Dec 14 '14 at 08:17
  • _p = new System.Diagnostics.Process(); _startInfro = new System.Diagnostics.ProcessStartInfo(); _startInfro.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; _startInfro.UseShellExecute = false; _startInfro.CreateNoWindow = true; – Barak Rosenfeld Dec 14 '14 at 08:19