I have a Windows application written in C# using winforms. I want to make sure that whenever someone starts it from any other application using process.start the UI is not shown and the application should start silently.
I do not have control over other applications so I can not use:
var p = new Process();
p.StartInfo = new ProcessStartInfo();
p.StartInfo.UseShellExecute = true;
p.StartInfo.WorkingDirectory = ConfigurationManager.AppSettings["exeFolder"].ToString(); p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.StartInfo.FileName = ConfigurationManager.AppSettings["exeName"].ToString();
p.Start();
Thanks for your replies. I am sorry to not have provided my solution earlier. I have resolved the problem and have documented the solution for someone else to use in future.
You can find the solution here.
How To
· Create a new windows project and delete the default form (Form1).
· In Program.cs create a new class and inherit it from Form.
· Please refer the code below.
· Now change the Main method. In Application.Run change the startup object from Form1 to ApplicationStartUp.