0

I run something like this:

string exec = @"/k" + @"7za.exe a -tzip " + name + ".zip \"" + name + "\"";
processStarter ps.run(exec);

startInfo settings:

        startInfo.WorkingDirectory = workingDir;
        startInfo.FileName = exe;
        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardOutput = true;

This zips some folder with command line and 7zip executable. Launched form winform app works fine, zips and goes to next line, but when app is launched form cmd with some arguments program hangs when debugging this line. It makes proper zip archive but program doesn't go to the next line.

I would appreciate any help.

Junuxx
  • 14,011
  • 5
  • 41
  • 71
wilk_u
  • 1
  • 3

2 Answers2

0

The /K tells the CMD instance not to terminate when its finished executing. You should replace this with /C. This this guidance from CMD's inbuilt help (CMD /?)

/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains

You should update your command to be:

@"/C" + @"7za.exe a -tzip " + name + ".zip \"" + name + "\""; 
joocer
  • 1,111
  • 1
  • 7
  • 11
0

I am having similar problem while using zip.exe from zip info, current i am at a place where i remove the

startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;

lines and it all magically work, i am still under investigation and when i find i solution and reason i will make sure to edit this answer.

EDIT:

Dear friend, my problem was that the standard output buffer becomes full and the operation stops from continuing, i used the zip.exe -q option which works in silent mode and stop writting errors this fixed the problem and showed me the reason of my problem, i think its the same with you.

Mumin Asaad
  • 180
  • 9