0

I am looking for the 7-zip command line call that is the equivalent to the explorer extension option of Add to "FolderName.zip":

7 Zip Explorer Extension

I have tried:

& 7z C:\path\To\SecondAttempt, C:\path\to\SecondAttempt.zip

And I get the following

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21

Command Line Error:
Unsupported command:
C:\path\to\SecondAttempt,

Does anyone know the command line equivalent of the explorer extension for 7-Zip?

Vaccano
  • 78,325
  • 149
  • 468
  • 850

2 Answers2

4

The shell extension invokes 7zG.exe, a GUI utility that shows a nice GUI window if this is what you were looking for. Using SysInternal ProcMon it's possible to look up the command line used, basically:

& "C:\Program files\7-Zip\7zG.exe" a -tzip -slp- "a.zip" "file1.txt" "file2.txt"
  • The file list can be put into a file and its name is specified after @ instead of the file names.
  • -slp- disables large page mode, and -slp enables compression speedup of large files
wOxxOm
  • 65,848
  • 11
  • 132
  • 136
2

Fo 7Zip this should be the correct syntax

 . .\7z.exe a C:\path\to\SecondAttempt.zip "C:\path\To\SecondAttempt"

But I would prefer to use directly .NET

Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory("C:\path\To\SecondAttempt","C:\path\to\SecondAttempt.zip")
autosvet
  • 869
  • 1
  • 9
  • 17
  • I would also prefer to use directly use .NET but that command (`-AssemblyName`) does not seem to work in Powershell 2.0 – Vaccano Aug 23 '16 at 23:33
  • That first command is what I was looking for. I was missing the `a` and had an extra comma. – Vaccano Aug 23 '16 at 23:34
  • 1
    If you can you upgrade to PowerShell 5.0 (5.1) it would be the best. 2.0 is default or Win 7 and I suggest to upgrade PS and .NET as well. – autosvet Aug 23 '16 at 23:35