I am new in Windows form application. I have created a Windows form. the entry point of my solution is as per the below
static void Main(string[] args)
{
Boolean bConsole = false;
for (int nArg = 0; nArg < args.Length; nArg++)
{
if (args[nArg].Equals("-Console", StringComparison.OrdinalIgnoreCase))
{
bConsole = true;
}
}
if (bConsole)
{
Form_Main form = new Form_Main();
form.Form_Main_Console();
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form_Main());
}
}
The application is working fine for windows form. How can I run it from console ? Can anyone help me regarding that?
Compile your application to a binary (let's say MyApp.exe).
Now in cmd.exe browse to the same directory (cd /path/to/exe) and type "MyApp.exe cmd1 cmd2".
cmd1 and cmd2 appear as strings in the "string[] args" parameter to your Main function. Do with them however you so please.
Eg:
cd %ProgramFiles%/Path/To/App
MyApp -Console whatever
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.