

Moreover, anyone can unzip that file and access your confidential content. Let's say you have a folder containing some confidential files and you want to create a zip file that is password protected and encrypted.Ĭreating a plain zip file is not wise as it provides no extra security. To make it work for 7z format, make following changes:Ĭhange target file name set DestZip=D:\Destinationtest\BACKUP.7zĮdit last line "%SevenZip%" a -mhe=on -pYourPassword "%DestZip%" -r "%BaseDir%\*.*"Īfter these changes, it will ask for password every time.In this tutorial we will learn to create password protected and encrypted zip file using the Terminal.

But this option does not work with zip format. To encrypt file name, you need to add -mhe=on option to encrypt file header. When I try to extract output file, it asks for password:

Set VarA=%%a&set VarB=%%b&set VarC=%%c&set VarD=%%d&set VarE=%%e&set VarF=%%f&set VarG=%%g&set VarH=%%h&set VarI=%%i REM Zip all files and folders echo Getting time. "%SevenZip%" a -pYourPassword -tzip "%DestZip%" -r "%BaseDir%\*.*" This is the point where you can add -p option. Last line of this batch file is responsible to execute 7z command line. It would have been easier for you if batch file was formatted properly. Set TimeStamp=%Year%%Month%%Day%_%Hour%%Minute%%Second%įor %%a in ("%DestZip%") do (set DestZip=%%~dpna-%TimeStamp%%%~xa) Set SevenZip=C:\Program Files\7-Zip\7z.exeįor /f "tokens=1-9" %%a in ('wmic.exe Path Win32_LocalTime Get Day^,DayOfWeek^,Hour^,Minute^,Month^,Quarter^,Second^,WeekInMonth^,Year ^| find /v ""') do ( Set DestZip=D:\Destinationtest\BACKUP.zip Any idea where do I put the -p command to make it work? I tried but it is not working for me. I have a script below which is working perfectly, all I need is to add a password & encryption while compressing.
