473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Help with app that is EITHER console app OR Windows app

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?

Jul 21 '05 #1
1 1611
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?

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am...
9
by: YZK | last post by:
Hello. I'm not a Web developer, just a user, and I think I may have somehow messed myself up majorly. I'm not quite sure how. Right now, javascript used by websites I go to either does not work at...
11
by: dhnriverside | last post by:
Hi peeps Ok, so I thought I'd have a go at making a console app in VS2k5... I haven't written any windows apps for years, let alone dos apps (been web programming) and I've hit a dumb error... ...
13
by: Siegfried Heintze | last post by:
I refered the engineer at my hosting service to http://support.microsoft.com/default.aspx?scid=kb;en-us;825738 where he tried to follow the directions there. He said there was no such file:...
8
by: Alison | last post by:
Hi, Al I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window...
1
by: Fred Iannon | last post by:
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)...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: James | last post by:
I'm interested in learning C++. I'm not sure exactly what this means. I'm currently a VB.NET/C#.NET programmer (both Windows Forms and ASP.NET). I am totally clueless when it comes to C++. I've...
5
by: Just_a_fan | last post by:
I can get a dump. I can send it in to M$. I can inspect it but cannot get it in my hands so I can not post it here and get comments and/or answers. Can I get hold of that dump somewhere? Is it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.