5

I have folder C:\Temp\ which has two file des.exe and input.abcd. des.exe is used to decrypt input.abcd. below 2 lined works in command prompt

cd C:\Temp\
des.exe XXXX input.abcd output.zip

why below does not work from c#

        string argument1 =  "/K cd C:\\Temp\\ ";
        string argument2 = "des.exe XXXX input.abcd output.zip" ;
        System.Diagnostics.ProcessStartInfo proc = new      System.Diagnostics.ProcessStartInfo();
        proc.FileName = @"C:\windows\system32\cmd.exe";
        proc.Arguments = String.Format("{0} {1}", argument1, argument2);
        proc.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;            
        System.Diagnostics.Process.Start(proc); 
1
  • no error but i don't see output.zip means it is not working. Commented Dec 20, 2011 at 16:29

2 Answers 2

8

You do not need to run cmd.exe as a process. All you need to do is run "c:\temp\des.exe" with the arguments of "XXXX input.abcd output.zip".

System.Diagnostics.Process.Start("c:\temp\des.exe", "XXXX input.abcd output.zip"); 

Be sure to give your arguments the correct full-paths as well if they are different from the temp dir.

Sign up to request clarification or add additional context in comments.

1 Comment

Try System.Diagnostics.Process.Start("c:\temp\des.exe", " XXXX c:\temp\input.abcd c:\temp\output.zip");.
0

The process you want to run is dec.exe, not cmd.exe. Try this, substitute {fullPath} with path to des.exe:

     string argument2 = "XXXX input.abcd output.zip";
     System.Diagnostics.ProcessStartInfo proc = new System.Diagnostics.ProcessStartInfo();
     proc.FileName = @"C:\\Temp\\des.exe";
     proc.Arguments = String.Format("{0} {1}",  argument2);
     proc.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
     System.Diagnostics.Process.Start(proc); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.