I am trying to figure out a way to select several files and folders in Windows Explorer and add them to a password protected .zip archive using a batch script, 7zip and a custom context menu item.

Currently I have a .bat file that looks like this:

pushd %~f1
"%programfiles%\7-zip\7z.exe" a Archive.zip  -pPASSWORD %1

(pushd is necessary because I am using a UNC path)

I have added this file to the right click context menu and it can be executed on all filetypes and folders.

My problem is that if I have the %1 at the end of the batch script (see above) it only adds the file I actually right-clicked on (regardless of how many files and folder I have selected), and if I leave out the %1 it adds all files and sub-folders in the current folder, not just those I selected.

Is there any way I could get this batch script to work like the "add to archive..." option of 7Zip (adding only the selected files and folder to an archive and nothing else)?

Thank you very much in advance!


Try replacing %1 with %* which will add all selected.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.