Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Is there a way to have 1 application that can start from Windows (clicking on the exe file from the explorer window) and from the command line?
Posted
Comments
Mike Meinz 1-May-13 13:03pm    
Any EXE can be started from a shortcut, by double-clicking on the .EXE file and from the command line.

If what you really meant to ask, was can an application take command line parameters or display a window for interactive use, the answer to that question is also yes.
Eugene Mayeski 1-May-13 13:09pm    
Mike, enlighten us, please, how does one application use default console when started from console, or shows no console when started from GUI process?
Mike Meinz 1-May-13 13:25pm    
In the application check to see if command line arguments are passed and if they are, parse the arguments and use methods of the Console Class. If no command line arguments are passed, show your main form to interact with the user.
Eugene Mayeski 1-May-13 13:26pm    
Console class will allocate a new console, no?
Mike Meinz 1-May-13 13:32pm    
No. Just use Console.WriteLine
There is no need to instantiate the Console Class. There are examples in the documentation Console Class

1 solution

Yes. Absolutely any application can be started both ways. Besides, even if you start anything from command line, it is still started "from Windows". There is no any difference. Explorer is just one of the applications, no different from other. Any application can be programmed to start a new process in exact same way as Explorer, CMD.EXE or anything else. Those are 100% equivalent ways.

It looks like you are not ready for programming, just yet. First, you need to learn how to use a computer as a plain user. I'm serious. You don't know enough about it yet, please get some more knowledge as a user.

—SA
 
Share this answer
 
Comments
Zoltán Zörgő 1-May-13 16:52pm    
You are the only one who read the question :) +5!
Sergey Alexandrovich Kryukov 1-May-13 16:59pm    
Thank you very much, Zoltán.
It's a pleasure to know, because in some other cases I often misread them... :-)
—SA
Sergey Alexandrovich Kryukov 1-May-13 17:06pm    
What exactly do you thing is rude? I think, even saying "good job" is more rude in case it's not true. If OP clarifies the question, we can discuss it, but so far, this is a correct answer, and yours is not. Perhaps you might decide that I'm rude with you, too, but at least my advice is friendly, I'm trying to help to overcome confusion, in your understanding, too. When I say that someone fails anything, I mean just that, nothing personal. This should not be a kindergarten. When people try to offense others on personal level, I don't hesitate to blame them in rudeness myself.
—SA
Sergey Alexandrovich Kryukov 1-May-13 17:19pm    
Ah, sorry, not I see that. Nevertheless, my notes about "rudeness" are still applicable. This is his opinion. If it's not correct, argue with your opinion. Most people are reasonable enough to consider other opinions and fix their inaccurate sayings. Or they would stand for their opinion. As soon as it does not come to personal offense, it's perfectly fine, no need to suspect personal attacks.

Maybe you did read the question, but your answer is not answering it. And, by the way, it would by fine. I often refuse to answer original question and address something which I think could be more helpful to the inquirer. And my answer reflect how I see it in this case...
—SA
Sergey Alexandrovich Kryukov 1-May-13 17:07pm    
Thank you very much, Ian. As I say above, nothing personal. And if you really down-voted and pointed out my mistake, I would only say thank you and fix myself. Everyone could see that I did that in a number of cases...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900