Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

Hi. I want to create 1 application in which first i want to read data from excel file. Then want to execute data using "Command prompt". whatever output i will get in the command prompt execution i want to capture into excel file again.

Does anyone help in the this application.
Please help me.
And thanks in advance.

Ranjeet Waje
Posted
Comments
ajit_machhe 9-Apr-12 2:33am    
execute data using command prompt ??

I guess i can help but you have to provide more info.
ranjeet.waje 10-Apr-12 3:16am    
Hey ajit,

In my window app, I hav one excel sheet. On button click I want take data from excel sheet row by row and run into the command prompt and then whatever output i will get from that want to export into the excel sheet again.

hey thank for support and please help.

Ranjeet waje

1 solution

Hi Ranjeet,

Here is solution for taking output of executed command

C#
private void button1_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.ProcessStartInfo processstart = new          System.Diagnostics.ProcessStartInfo("cmd", "/c " + "dir");
            processstart.RedirectStandardOutput = true;
            processstart.Argument ="";
            processstart.UseShellExecute = false;
            processstart.CreateNoWindow = true;
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo = processstart;
            proc.Start();
            textBlock1.Text  = proc.StandardOutput.ReadToEnd();

        }


here i have chosen "dir"(simple dos command)and took output to textBlock

you can have string here for take a out put.

you can send parameter to command using processstart.Argument = "//here will be parameter";

do let me know if it works for you

i guess you can read from excel file...

else i will update that also.
 
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