Click here to Skip to main content
15,917,793 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Dear sir, I wanna attach cmd with winforms application. Is it possible?
If possible, then how?
Posted
Updated 2-Aug-15 3:42am
v2
Comments
Afzaal Ahmad Zeeshan 2-Aug-15 9:41am    
Cmd, you mean Command prompt?

You cannot attach it, instead you link one application to another. Be more specific please.
Kornfeld Eliyahu Peter 2-Aug-15 9:53am    
Do you mean to open command prompt from your application (probably with specific properties)?
[no name] 2-Aug-15 11:17am    
My complete and total guess as to what you want would be System.Diagnostics.Process.Start.
Sergey Alexandrovich Kryukov 2-Aug-15 17:06pm    
If you mean CMD.EXE, using it makes no sense at all. This is just an application; the notion "attach" makes no sense. What do you want to achieve?
—SA

1 solution

If you mean you want to supply command line parameters to a WinForms app, then yes, you can.
All you need to do is:
C#
string[] args = Environment.GetCommandLineArgs();
in you form code, and you will be given them.
When you register you app as handling a file extension, then a double click in Windows Explorer will pass the file path to your app via these arguments, for example - or you can add them to a shortcut on your desktop.

If that isn't what you want, then you need to specify rather better exactlky what you are trying to do, bearing in mind that we can't see your screen, access your HDD, or read your mind.
 
Share this answer
 

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