Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have written this code to
1->browse the folder in which the exe is there
2->when i click the button the commanad prompt opens with the browsed path and comes to ABC folder
3->in ABC folder i have xyz.exe and few doc files
4->now i want the command prompt to display like this

path>xyz.exe 123_A.zip

5- note there are many zip files in it.
6->then press enter by itself and do the rest all things.



C#
private void brwz_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            DialogResult dr = fbd.ShowDialog();
            if (dr == DialogResult.OK)
            {
                path.Text = fbd.SelectedPath;
            }
        }

        private void button_Click(object sender, EventArgs e)
        {
            try
            {            
                ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");
                psi.WorkingDirectory = path.Text;
                                
                Process.Start(psi);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Posted
Updated 22-Apr-13 21:34pm
v4
Comments
Ian A Davidson 23-Apr-13 3:50am    
Why would you want to start the command line to do it? Why not just execute the required executable with the required parameters?
Regards,
Ian.
Ajinkya Patil 23-Apr-13 3:52am    
the file is for creating the signature which should run in command only
like the
path of the folder>xyz.exe abc_001.zip
Ajinkya Patil 23-Apr-13 4:58am    
I guess you have not understood my question.

Once again i will tell you the process.

suppose the path is c:\users\Raj\Desktop\ABCD

in command prompt i will set the folder destaion as the Below
C:\Users\Raj\Desktop\ABCD>

In this ABCD folder i have got xyz.exe, abc_001.zip, ijk_001.zip, pqr_001.zip

now i want the command prompt to show the below
C:\Users\Raj\Desktop\ABCD>xyz.exe abc_001.zip
Ian A Davidson 23-Apr-13 9:17am    
No, I understood the question. I'm asking "Why?".
why would you want to write a C# program, which then tries to control the cmd environment to do things which you can easily do directly from the C# program itself (see Griff's solution).
If you want to do it in the command line, write a .cmd (batch) file instead.
Regards,
Ian.
Ajinkya Patil 23-Apr-13 9:25am    
Where can i find the solution... Can u plz post the link for this solution

1 solution

All you need to do is replace
C#
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");
psi.WorkingDirectory = path.Text;
                                
Process.Start(psi);
With:
C#
Process p = new Process();
p.StartInfo.FileName = @"D:\xyz.exe";
p.StartInfo.Arguments = "abc_001.zip abc_002.zip";
p.Start();
 
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