Question

I am using 7zip on powershell because I need to zip some folders. This is the code I am using:

Set-StrictMode -Version "2.0"
Clear-Host
$7Zip_ProgramPath="C:\Program Files\7-zip\7z"
$Destination = "c:\temp\7ztest41.zip"
$Source = "c:\temp\homes\homeuser002"
$Option = "a"
$Command = "$7Zip_ProgramPath $Option $Destination $Source"
#$Command="C:\Program Files\7-zip\7z a c:\temp\7ztest.zip c:\temp\homes\homeuser002"
$ManagementClass=[System.Management.ManagementClass] "\\.\ROOT\cimv2:Win32_Process"
#kürzer: $$ManagementClass=[WmiClass] "Win32_Process"
$StartupOptions=[WmiClass] "Win32_ProcessStartup"
$StartupOptions.PsBase.Properties["ShowWindow"].Value=1
$null=$ManagementClass.Create($Command,$Null,$StartupOptions)'

I got this code from this page here: http://www.powershellpraxis.de/index.php/ntfs-filesystem/laufwerke-ordner-dateien-und-freigaben#2.1.2.5.2%20Packen%20mit%207-Zip

Everything is working quite good, except for the fact that I do not want to compress my files when using this method. I have a folder which is 67 MB big, but after zipping this folder it is only 55 MB big. Maybe I do not fully understand this code but I want to change the compression option and do not know where and how. Does anybody know?

Was it helpful?

Solution

Your command line is only specifying an 'Add' operation.

$Option = "a"

The 'Add' option does not disable compression in 7z.exe. You need to explicitly configure the compression option to specify 'no compression'.

$Option = 'a -mx=0'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top