Advertisement

04.14.2008 at 10:45AM PDT, ID: 23321117
[x]
Attachment Details

Shell command via windows form app

Asked by dnfeldman in .Net Editors & IDEs, C# Programming Language, Microsoft Visual C#.Net

Tags:

I need to run shell commands from a windows form app in C#.  I have written the attached code but it does not work how I like.  With the "/C" in the command the shell opens the command is issued and then the terminal closes.  If I remove the "/C" the terminal opens and then nothing happens.  The command is never issued.  How can I solve this?  The reason I need the terminal to stay open is that I need to run a chain of commands in the same terminal.

The attached code isnt the command I will need to run but just a simple example.

            Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
System.Diagnostics.Process process1;
            process = new System.Diagnostics.Process();
            process.EnableRaisingEvents = false;
 
            string strCmdLine;
            cmdLine = "/C dir > output.txt";
            System.Diagnostics.Process.Start("CMD.exe", cmdLine);
            process.Close();
 
Loading Advertisement...
 
[+][-]04.14.2008 at 10:50AM PDT, ID: 21352077

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 11:54AM PDT, ID: 21352678

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 12:18PM PDT, ID: 21352896

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 12:21PM PDT, ID: 21352914

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 12:46PM PDT, ID: 21353146

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 12:52PM PDT, ID: 21353202

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 01:07PM PDT, ID: 21353344

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 01:28PM PDT, ID: 21353529

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 01:48PM PDT, ID: 21353730

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, C# Programming Language, Microsoft Visual C#.Net
Tags: C#
Sign Up Now!
Solution Provided By: tgerbert
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.14.2008 at 08:26PM PDT, ID: 21355721

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 09:05PM PDT, ID: 21355865

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 10:32PM PDT, ID: 21356139

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628