See the following code...
Do these steps...
Take a console application project in VS...
Let Class1 contains the entry point..
class Class1{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args){
if(args.Length==0){
Console.WriteLine("Application started in Windows mode...");
System.Windows.Forms.Application.Run(new Form1());
Console.WriteLine("Application terminated...");
DoExecCommands();
}
else
DoExecCommands();
}
static void DoExecCommands(){
string cmdString=String.Empty;
while(cmdString.ToLower()!="exit"){
Console.WriteLine("Type exit to quit the application.");
Console.WriteLine("Command:");
cmdString=Console.ReadLine();
/*
* Do something according to the command
*
*/
}
}
}
Do not foget to add a reference to System.Windows.Forms dll and a Form.
Hope this will meet your requirements
regards
Sujith S.Varier
"Fred Iannon" <Fr********@yahoo.com> wrote in message
news:01****************************@phx.gbl...
All,
I have developed an application that needs to run
in one of two modes:
(1) IF NO command line parms are provided I would
like it to run as a Window form application
(i.e. /target:winexe) with a Main form, etc. and with
execution returing to the command line AS SOON AS the
program STARTS
(2) If a command line parm IS provided I would
like it to run as a console application (i.e. /target:exe)
with NO UI and with execution returing to the command line
ONLY AFTER THE PROGRAM COMPLETES...This makes it nice to
be used in a batch file / automated and to be able to
determine when the program execution has completed.
I could make two different project files/.slns but this is
kind of tedious. In reality all I need is to be able to
change that one setting (/target) AFTER determining if
command line parms are present or not....However that
option is used by the compiler to build the .exe :-)
Does anyone have any suggestions?