Search code examples
pythoncommand-linesubprocess7zip

Python Creating a 7zip archive with command line


So I am trying to run a command line argument to create a 7zip archive as below:

rc = subprocess.run([path, 'a', 'archive.7z', '-psecret', 'mhe', 'log.log'])

However, all it is doing is opening 7zip and not creating archive.7z as intended.

Any reason why?


Solution

  • Adding comment as answer in case others come across this:

    When you say 'opening 7zip' I imagine you mean the file manager GUI, which means you are hitting the wrong executable. You want path to end in 7z.exe not 7zFM.exe.