I have a console application which can also open winform under certain conditions.Processing(its a database export utility) and be done either through form or commandline. but the form is always associated with command prompt. i mean when i close the console the form get closed as well.My requirement is that when form is launched , the command prompt is closed by itself without closing the form.
[STAThread]
public static void Main(string[] args)
{
if(hastolaunchform)
{
Application.Run(new Form1());
}
else
{
Console.WriteLine("started");
try
{
dataclass.extract();
console.writeline("finish");
}
catch (Exception e)
{
Console.WriteLine("An error occur");
}
}
}
What you have here is an app that has a gui or not.
What you need is a gui version of it that optionally can be run from the CLI, ie it needs to be another exe, or the same exe with different command line parameters, though be careful with that, otherwise it could just keep launching another version of itself until windows dies.
At least I think that’s what you are asking.
CLI arguments
MyApp.Exe –GUI
–GUI will apears in args[1].
So something like