2

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?

1 Answer 1

4

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'
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you this was the option I was looking for, but I could not find the page you are refering to. I gave you the answer.
When I write it like that 7zip does not start. Is there another form of spelling possible?
Ok I got it. $Option = 'a -mx=0 That worked for me perfectly fine.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.