Execute Command for 7-Zip

Post Reply
User avatar
magnussandstrom
Advanced member
Posts: 345
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Execute Command for 7-Zip

Post by magnussandstrom »

Hi, I'm trying to use Execute command in Switch to compress and encrypt files using 7-Zip command line program.

When I run the following command 7z a -tzip out.zip in.pdf in Windows Command Promt I get a successful ZIP-file. But in Switch I keep getting error code 1 (https://sevenzip.osdn.jp/chm/cmdline/exit_codes.htm).

The Command or Path is set to: C:/Program Files/7-Zip/7z.exe and the Argument is: a -tzip %1 %2

Any ideas what I'm doing wrong?

ps I'm going to use the XML Pickup for setting the password (but I left this out of the scope for now).
switch_1.jpg
switch_1.jpg (241.22 KiB) Viewed 4425 times
switch_2.jpg
switch_2.jpg (79.66 KiB) Viewed 4425 times
Zoranj
Member
Posts: 107
Joined: Tue Sep 20, 2016 7:37 pm
Location: Canada

Re: Execute Command for 7-Zip

Post by Zoranj »

First swap %1 and %2 as 7zip needs output path first, than input so it is %2 %1
Also if you have any spaces in your path input or output, it is safer to put quotation marks around it so final commands look like:
a -tzip "%2" "%1"

I hope this helps.
User avatar
magnussandstrom
Advanced member
Posts: 345
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Execute Command for 7-Zip

Post by magnussandstrom »

I got help from Jan to solve this. The main issue was that 7zip creates the compressed file before populating it with compressed data. I use a set folder path instead of %2 and it solved the issue. The varible in my flow looks like this: a -tzip -scrcSHA256 "\\myfolderpath\[Job.NameProper].zip" "%1" -r -p[Job.PrivateData:Key="password"]

a = Add files to archive
-t = Output file type
-scrc = Encryption
-r = Recurse subdirectories
-p = Password

Background: I build this flow to encrypt and send sensitive files to clients etc. I let Switch generate the password and sending the password by SMS from Switch and the file URL by email. It's a really neat flow!

This is the Execute Command settings:
7zip.jpg
7zip.jpg (83.79 KiB) Viewed 4232 times
User avatar
magnussandstrom
Advanced member
Posts: 345
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Execute Command for 7-Zip

Post by magnussandstrom »

And this is the finished flow:
flow.png
flow.png (116.91 KiB) Viewed 4192 times
Post Reply