How to password protect zip file?


How can I password protect a zip file created from Invoke method (System.IO.Compression.ZipFile)?

I tried to use UiPath.Cryptography.Activities.EncryptFile but the zip file is unable to be unzip in windows.


Hi @emily

For instance, If you want to extract all *.txt files from archive c:\ to c:\output folder,
use Start Process activity and set Filename to “C:\Program Files\7-Zip\7z.exe”,
set Arguments to “e c:\ -oc:\output *.txt -r”.

1 Like

Hi wusiyangjia, thanks for the reply! I’m not trying to extract zip file but rather i want to set password for a zip file. Do you know how should I do this? Thanks.

Hi @emily

Maybe you can archive a zip file with password after extracting, as below.
C:\Program Files\7-Zip\7z.exe e c:\ -oc:\output *.txt -r
C:\Program Files\7-Zip\7z.exe a c:\ -p123 c:\output*.txt -r

1 Like

Hi @wusiyangjia, do you mean to use Invoke Power Shell? I tried the following but face the following error:

Invoke Power Shell: The term ‘C:\Program Files\7-Zip\7z.exe a D:\ “D:\output”’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Did we try with this component, buddy

Cheers @emily


Hi @emily

For instance, there are two methods to extract from a zip file.
1.Use Start Process activity and set Filename to “C:\Program Files\7-Zip\7z.exe”,
set Arguments to “e c:\ -oc:\output *.txt -r”.
2.Use Invoke Power Shell activity with checking IsScript and change TypeArgument to String and set CommandText as follow.
“& ““C:\Program Files\7-Zip\7z.exe”” @(”“e”",("“c:\”"),(""-oc:\output""),(""*.txt""),""-r"") | out-string;"

1 Like

Hi @Palaniyappan, i did but the password function is not working for me. The zip file could be open without asking for password.

thanks @wusiyangjia, it works now! I have also added the password function, pls see below for those who may also face the same issue.


1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.