0

I'm running 7-zip in a script and capturing the output in a variable:

$Results = (7z a $OutputFileName $InputFolder -bt -mm=LZMA -tzip) #will run and return no output

Occasionally the script will select some parameters that are not compatible, e.g. setting LZMA2 compression to a .zip archive:

$Results = (7z a $OutputFileName $InputFolder -bt -mm=LZMA2 -tzip) 

when this runs, 7-zip somehow escapes the variable binding and writes directly to the console:

 System ERROR: 
 Not implemented

How do I find the error stream that 7-zip is writing to and capture/suppress it?

  • how about fixing the root cause (faulty parameters)?! to suppress anything you can do ```[void](7z a $OutputFileName $InputFolder -bt -mm=LZMA2 -tzip)``` – Toni Oct 03 '22 at 15:20
  • @Toni Each parameter is stored as an array. I'm running nested `foreach` commands on the array to cycle through every possible option. e.g. `$ProtocolArray = ("Deflate","Deflate64","LZMA","PPMd","BZip2","LZMA2","BCJ","BCJ2")` The end goal is to determine the most space/time efficient settings. I don't know which settings are incompatible, so I figured trying every one, and those that are incompatible are thrown out of the results. I don't want to void the entire output, I just want to suppress the error message appearing. – GallantChaos Oct 03 '22 at 15:31
  • 1
    See [this answer](https://stackoverflow.com/a/73909728/7571258) for an example to capture the error stream in a separate variable. – zett42 Oct 03 '22 at 15:33
  • @zett42 Took a minute, but that did the trick. Thanks for the help. – GallantChaos Oct 03 '22 at 15:50

0 Answers0