Need to zip and password protect files in as few steps as possible

How can I create a batch file that will password protect the compressed files?

Use the -p option:

-p (set Password) switch

Specifies password.

Syntax

 -p{password}
  • {password} Specifies password.

Examples

7z a archive.7z -psecret -mhe *.txt

compresses *.txt files to archive.7z using password "secret". Also it encrypts archive headers (-mhe switch), so filenames will be encrypted.

7z x archive.zip -psecret

extracts all files from archive.zip using password "secret".

Source -p (set Password) switch