

It's one of the first defensive measures to put into place. Password-protected files are an attempt to prevent unwanted eyes from accessing your information by protecting it with a password. In this article, we look at what a password-protected zip file is, what four of the most common ways are to set up a password and the benefits are of using this mode of security. It's important to understand how to password-protect zip files, especially when handling sensitive information. They're often used within different organisations to keep sensitive information from leaking to the press, the competition or simply internally. 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.A password-protected file is relatively self-explanatory in that it's set up to protect the security of the file from unwanted eyes. 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.
